Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:说说两个简单公式.In Reply To:说说两个简单公式. Posted by:KosonLau at 2007-04-28 21:22:36 > k=(sqrt(1+8*n)-1)/2,即子序列的长度不会超过k. 接着从1到k一个一个判断 a=(2*n-k*k+k)%(2*k)是否为0,如果是则总数加1,否则继续循环. > > #include<stdio.h> #include<math.h> int main() { int n,k,i; int sum=0; scanf("%d",&n); k=(int)(sqrt(1+8*n)-1)/2; for(i=1;i<=k;i++) if((2*n-k*k+k)%(2*k)==0) sum++; printf("%d",sum); return 0; } 为啥答案是错误的呢? Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator