算法
qq641542616
这个作者很懒,什么都没留下…
展开
-
数字字符串的基数排序
#include/** * created by:shishuai * QQ:641542616 * 函数功能:对多组相同位数的数字字符数组进行排序 * 函数实现方法:基数排序 * 时间复杂度:O(n) * 参数n:待排序的数字字符数组的位数 * 参数(*a)[n]:待排序的数字字符数组 * 参数p:待排序的起始数组 * 参数q:待排序的终止数组 */void base_sort(int n,ch原创 2014-10-08 15:07:46 · 718 阅读 · 0 评论 -
【Peking University Online Judge】3617(Best Cow Line)
#includeint main(void){ int n,i,j,k,l; while(scanf("%d",&n)!=EOF){ char in[n],out[n],c; for(i=0;i<n;i++){ while((c=getchar())=='\n') continue; in[i]=c; out[i]='\0'; } i=0; j=原创 2015-01-30 20:37:16 · 450 阅读 · 0 评论 -
【Peking University Online Judge】1006(Biorhythms)
#includeint main(void){ int p,e,i,d,n=1,sum; while(scanf("%d%d%d%d",&p,&e,&i,&d)!=EOF&&p!=-1) { sum=1; p%=23; e%=28; i%=33; while(sum%23!=p||sum%28!=e||sum%33!=i) sum++; if(su原创 2015-01-30 20:22:19 · 480 阅读 · 0 评论 -
【Peking University Online Judge】1003(Hangover)
#includeint main(void){ double a,sum; while(scanf("%lf",&a)!=EOF&&a!=0){ sum=0; int i=1; sum+=1/(double)(i+1); while(sum<a){ i++; sum+=1/(double)(i+1); } printf("%d card(s)\n",i);原创 2015-01-30 20:19:05 · 594 阅读 · 0 评论 -
【Peking University Online Judge】3253(Fence Repair)
#includevoid push(__int64* heap,__int64 n);__int64 pop(__int64* heap);int main(void){ __int64 n,i,heap[20000],min1,min2,sum; scanf("%I64d",&n); __int64 a[n]; heap[0]=0; sum=0; for(i=0;i<n;i++原创 2015-01-30 20:35:37 · 481 阅读 · 0 评论 -
【Peking University Online Judge】1183(反正切函数的应用)
#include int main(void) { __int64 a,b,c,sum; while(scanf("%I64d",&a)!=EOF){ sum=0; c=9223372036854775807; for(b=a+1;b<=((double)a*b+1)/(b-a);b++){ if((a*b+1)%(b-a)==0&&(a*b+1)/(b-a)<c){原创 2015-01-30 20:26:53 · 386 阅读 · 0 评论 -
【Peking University Online Judge】1008(Maya Calendar)
#include#includeint haab_change(char *a);int main(void){ int n; char tzolkin[20][10]={ {'i','m','i','x','\0'}, {'i','k','\0'}, {'a','k','b','a','l','\0'},原创 2015-01-30 20:24:56 · 540 阅读 · 0 评论 -
【Peking University Online Judge】1005(I Think I Need a Houseboat)
#includeint main(void){ double x,y; int n; while(scanf("%d",&n)!=EOF){ for(int i=0;i<n;i++){ scanf("%lf%lf",&x,&y); int j=0; while(100*j/3.14159265<x*x+y*y) j++; printf("Property原创 2015-01-30 20:21:48 · 405 阅读 · 0 评论 -
【Peking University Online Judge】1189(钉子和小球)
#include#includeint main(void){ int n,m; char c; while(scanf("%d %d",&n,&m)!=EOF){ char a[n*(n+1)/2]; __int64 b[(n+2)*(n+1)/2]; for(int i=0;i<n*(n+1)/2;i++){ while((c=getchar())=='\n'||c原创 2015-01-30 20:29:15 · 475 阅读 · 0 评论 -
【Peking University Online Judge】1012(Joseph)
#include int main(){ int k; for(;;) { scanf("%d",&k); if(!k) break; switch(k) { case 1:printf("2\n");break; case 2:printf(原创 2015-01-30 20:26:16 · 522 阅读 · 0 评论 -
【Peking University Online Judge】1007(DNA Sorting)
#includeint main(void){ int m,n; scanf("%d%d",&n,&m); int a[m][n+1],b[n],c; for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { while((c=getchar())==' '||c=='\n') continue;原创 2015-01-30 20:23:52 · 380 阅读 · 0 评论 -
【Peking University Online Judge】1004(Financial Management)
#includeint main(void){ double a[12],sum=0; for(int i=0;i<12;i++){ scanf("%lf",&a[i]); sum+=a[i]; } printf("$%.2f\n",sum/12); return 0;}原创 2015-01-30 20:20:06 · 473 阅读 · 0 评论 -
【Peking University Online Judge】1002 (487-3279)
#include#includeint compare_string(char*,char*);void base_sort(char (*a)[7],int p,int q);int main(void){ long n; while(scanf("%ld",&n)!=EOF){ char c,a[n][7]; int b[n],index=0; getchar();原创 2015-01-30 20:15:50 · 562 阅读 · 0 评论 -
【Peking University Online Judge】2431(Expedition)
#includevoid push(__int64* heap,__int64 n);__int64 pop(__int64* heap);void init(__int64* heap);void quiksort(__int64 a[][2],__int64 low,__int64 high);int main(void){ __int64 n,l,p,i,k,heap[10000原创 2015-01-30 20:31:18 · 454 阅读 · 0 评论 -
【Peking University Online Judge】1852(Ants)
#includeint main(void){ __int64 len,n,N,min,max,i,j,max_ant,min_ant; scanf("%I64d",&N); for(j=1;j<=N;j++){ scanf("%I64d%I64d",&len,&n); __int64 ant[n]; for(i=0;i<n;i++) scanf("%I64d",&ant原创 2015-01-30 20:30:44 · 374 阅读 · 0 评论 -
【Peking University Online Judge】3069(Saruman's Army)
#includeint main(void){ __int64 r,n,i,j,k; while(scanf("%I64d%I64d",&r,&n)!=EOF&&r!=-1&&n!=-1){ __int64 L[n],sum=0; for(i=0;i<n;i++) scanf("%I64d",&L[i]); for(i=0;i<n-1;i++){ for(j=i+1;原创 2015-01-30 20:34:12 · 429 阅读 · 0 评论 -
【Peking University Online Judge】2453(An Easy Problem)
#includeint main(void){ int a,count=0,b; while(scanf("%d",&a)!=EOF&&a!=0) { b=a+1; count=count_of_1(a); while(count!=count_of_1(b)) b++; printf("%d\n",b); } return 0;}原创 2015-01-30 20:32:15 · 697 阅读 · 0 评论 -
谈谈人工智能、围棋与数学
最近几天,AlphaGo与围棋世界冠军李世石的对弈引起了全世界的关注,已然成了历史性的事件。今天下午第四场比赛结束,由于AlphaGo程序出现bug,使得李世石获得了唯一的一次胜利。这自然凸显出人工智能的强大,大家觉得,计算机的计算速度之快,只要遍历完所有可能的情况,自然会胜过人类。其实,这是没有真正理解围棋困难程度的表现。AlphaGo与李世石的对局原创 2016-03-14 00:42:21 · 2347 阅读 · 0 评论