最少乘法次数

#include <stdio.h>int main(){ int n; scanf("%d",&amp;n); while(n--) { int m,sum=0,t=0; scanf("%d",&amp;m); while(m) { if(m&amp;1) sum++; m>>=1; t++; } printf("%d\n",sum+t-2); } return 0;}
默认分类 | 2012-04-04 19:24 | 阅读 1277 次 | 评论 0 条

大数的阶乘问题代码

#include <stdio.h>int main(){ int a[5000]={0,1},co=1,n; scanf("%d",&amp;n); for(int i=2;i<=n;i++) { int jinwei=0; for(int j=1;j<=co;j++) { a[j]=a[j]*i+jinwei; if(a[j]/10000) { jinwei=a[j]/10000; a[j]%=...
默认分类 | 2012-04-01 20:23 | 阅读 1090 次 | 评论 0 条

好水的题

描述 Given two strings A and B, whose alphabet consist only ‘0’ and ‘1’. Your task is only to tell how many times does A appear as a substring of B? For example, the text string B is ‘1001110110’ while the pattern string A is ‘11’, you should output 3, because the pattern A appeared at the posit ...
默认分类 | 2012-04-01 14:40 | 阅读 821 次 | 评论 0 条
文章分类
最新评论