
算法
辉的探索之路
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
poj2739
Sum of Consecutive Prime Numbers #include "math.h" #include "stdlib.h" #include using namespace std; int main() { int max=10000; int res[1230]; memset(res,0,1230); res[0]=2; int num=1; for(int i=3;i>x; while(x!=0) { int x_num=0;原创 2010-12-30 15:42:00 · 1065 阅读 · 0 评论 -
新boj4
<br />Number Sequence<br />#include <iostream> using namespace std; int leng(int num) { int i=1; num=num/10; while(num!=0) { i++; num=num/10; } return i; } int main() { int count,i,j,k; char num_原创 2011-05-05 10:02:00 · 456 阅读 · 0 评论 -
新boj84
<br />Android key<br />#include <stdio.h> #include <stdlib.h> #include <memory.h> int res=0; void check(int **score,int Max,int m,int n,int row,int col,int step) { if(step==1) score[row][col]=1; if(step==Max) { res++;原创 2011-05-01 16:47:00 · 579 阅读 · 0 评论 -
新boj3
#include #include int cmp ( const void *a , const void *b){ return *(double *)a - *(double *)b;} int equ(double *trace,int *rank,int rowMax){ int i; for(i=1;i { if(trace[i-1] else if(trace[i-1]==trace[i]&&rank[i-1]>rank[i])return原创 2011-05-01 15:42:00 · 683 阅读 · 0 评论 -
boj67
<br />在世界中心呼唤爱<br /><br />#include <iostream> using namespace std; struct node { int value; node* left; int left_count; node* right; int right_count; }; node * insert(node * head,node * new_node) { if(head==NULL||new_node==NULL)return NU原创 2011-05-23 20:59:00 · 643 阅读 · 0 评论 -
poj2965
The Pilots Brothers' refrigerator<br />#include "iostream" #include "math.h" using namespace std; unsigned short int flips[16]={0xf888,0xf444,0xf222,0xf111,0x8f88,0x4f44,0x2f22,0x1f11, 0x88f8,0x44f4,0x22f2,0x11f1,0x888f,0x444f,0x222f,0x11原创 2011-01-10 15:17:00 · 636 阅读 · 0 评论 -
poj1753
Flip Game<br />#include "iostream" using namespace std; unsigned short int flips[16]={0xc800,0xe400,0x7200,0x3100,0x8c80,0x4e40,0x2720,0x1310, 0x08c8,0x04e4,0x0272,0x0131,0x008c,0x004e,0x0027,0x0013}; int min1=16; unsigned short int poww原创 2011-01-09 13:51:00 · 2717 阅读 · 1 评论 -
poj3094
Quicksum<br />#include "iostream" #include "math.h" using namespace std; int main() { char str[256]; memset(str,0,256); cin.getline(str,256); while(!(str[0]=='#'&&str[1]==0)) { int checksum=0; int len=strlen(s原创 2011-01-03 16:10:00 · 531 阅读 · 0 评论 -
poj2255
Tree Recovery<br />#include "iostream" #include "math.h" using namespace std; #define Max 27 void left_inorder(char* str1,char *str2,char *res_l,char *res_r); void left_pre(char* str1,char *str2,char *res,char *res2) { char left[Max]; cha原创 2011-01-03 12:57:00 · 788 阅读 · 0 评论 -
poj3006
Dirichlet's Theorem on Arithmetic Progressions<br />#include "iostream" #include "math.h" using namespace std; bool isPrime(int x); int main(int argc, _TCHAR* argv[]) { int a,d,n; cin>>a; cin>>d; cin>>n; while(a!=0||d!=0||n!=0原创 2011-01-02 20:28:00 · 716 阅读 · 0 评论 -
如何读取整行
<br />直接用cin或者scinf读取字符串,回自动隔断空格和回车,例如要读取“Hello World”就只能按“Hello”和“World”两个串读取。<br />此时需要使用cin.getline()函数,使用实例如下:<br />#include "iostream" using namespace std; int main() { char m[20]; cin.getline(m,5); cout<<m<<endl; return 0; } <br />输入:abcdefg原创 2011-01-03 15:52:00 · 670 阅读 · 0 评论 -
poj1503
Integer Inquiry<br />#include "iostream" #include "math.h" using namespace std; bool isEnd(char *str) { if(str[0]=='0'&&str[1]==0)return true; else return false; } void add(char *num1,char *num2); void move(char *num); int main() {原创 2011-01-02 00:02:00 · 458 阅读 · 0 评论 -
poj3299
Humidex<br />#include "iostream" #include "math.h" using namespace std; void formula(double& t,double& d,double& h); int main(int argc, _TCHAR* argv[]) { char cmd; cin>>cmd; while(cmd!='E') { double t=200,d=200,h=200;原创 2011-01-01 20:06:00 · 775 阅读 · 0 评论 -
poj2159
Ancient Cipher#include "iostream" #include "math.h" using namespace std; int compare(int *str1,int *str2); int main(int argc, _TCHAR* argv[]) { char old[101]; int s1[26]; int s2[26]; for(int j=0;j<26;j++) { s1[j]=0;原创 2011-01-01 20:04:00 · 512 阅读 · 0 评论 -
ACM中无输入结束提示时如何判断到达EOF
1.while((scanf"%d,%d",&m,&n)==2) { //... }2.while((scanf"%d,%d",&m,&n)!=EOF) { //... }3.while(cin>>m>>n) { //... }原帖地址:http://blog.youkuaiyun.com/super_chris/archive/2009/08/29/4495919.aspx转载 2011-01-03 12:46:00 · 720 阅读 · 0 评论 -
poj1083
<br />Moving Tables<br />#include "math.h" #include "stdlib.h" #include<iostream> using namespace std; int comp(const void*p1,const void *p2) { return (*((int *)p1))>(*((int *)p2))?-1:1; } int main() { int corridor[200]; int T,N; cin>>T;原创 2010-12-31 10:04:00 · 749 阅读 · 0 评论 -
poj2262
<br />Goldbach's Conjecture<br />#include "math.h" #include "stdlib.h" #include<iostream> using namespace std; bool isprime(int x); int main() { int num; cin>>num; while(num!=0) { int i; for(i=3;i<num/2+1;i++) { if(isprime(i)&&is原创 2010-12-31 15:26:00 · 719 阅读 · 0 评论 -
m进制转n进制(任意进制转换)
<br />m进制转n进制(任意进制转换)<br />/*!/author LiuBao/date 2011/4/10/brief m进制转n进制,主流实现方式*/ #include <stdio.h> /*!m进制(数字)字符串转为n进制字符串。(先由m进制转为10进制,再由10进制转为n进制)/param dest 转换完毕的n进制字符串/param n 目的进制数(十六进制填16、二进制填2等)/param src 初始m进制字符串/param m 初始进制数,与目的进制数表示方法相同/warn转载 2011-05-07 13:17:00 · 1438 阅读 · 0 评论