摘要: 阶乘因式分解(二)时间限制:3000 ms | 内存限制:65535 KB难度:3描述给定两个数n,m,其中m是一个素数。将n(0int main(){ int s; scanf("%d",&s); while(s--) { int i,n,m,a=0,b=0,c=0; int count=0; scanf("%d %d",&n,&m); while(n!=0) { count+=n/m; n=n/m; } printf("%d\n",count); } return 0;}解决这道题的原理很简单,就是看看n里 阅读全文
posted @ 2013-08-19 21:38 王莜轩 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 最少乘法次数时间限制:1000 ms | 内存限制:65535 KB难度:3描述给你一个非零整数,让你求这个数的n次方,每次相乘的结果可以在后面使用,求至少需要多少次乘。如24:2*2=22(第一次乘),22*22=24(第二次乘),所以最少共2次;输入第一行m表示有m(1int main(){ int n; scanf("%d",&n); while(n--) { int m,count=1; scanf("%d",&m); if(m<=2) count=m/2; else { while(m!=2) { if(m%2==0) { 阅读全文
posted @ 2013-08-19 16:01 王莜轩 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 取石子(一)时间限制:3000 ms | 内存限制:65535 KB难度:2描述一天,TT在寝室闲着无聊,和同寝的人玩起了取石子游戏,而由于条件有限,他/她们是用旺仔小馒头当作石子。游戏的规则是这样的。设有一堆石子,数量为N(1#includeint main(){ int n; scanf("%d",&n); while(n--) { int a,b; scanf("%d %d",&a,&b); if(a<=b) printf("Win\n"); else { if(a%(b+1)==0) printf 阅读全文
posted @ 2013-08-19 11:58 王莜轩 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 数的长度时间限制:3000 ms | 内存限制:65535 KB难度:1描述 N!阶乘是一个非常大的数,大家都知道计算公式是N!=N*(N-1)······*2*1.现在你的任务是计算出N!的位数有多少(十进制)?输入首行输入n,表示有多少组测试数据(n#includeint main(){ int n; scanf("%d",&n); while(n--) { int i,m,k; double len=1; scanf("%d",&m); for(i=1;i<=m;i+ 阅读全文
posted @ 2013-08-19 00:47 王莜轩 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Dinner时间限制:100 ms | 内存限制:65535 KB难度:1描述Little A is one member of ACM team. He had just won the gold in World Final. To celebrate, he decided to invite all to have one meal. As bowl, knife and other tableware is not enough in the kitchen, Little A goes to take backup tableware in warehouse. There are 阅读全文
posted @ 2013-08-19 00:13 王莜轩 阅读(263) 评论(0) 推荐(0) 编辑