| ||||||||||
| 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 | |||||||||
一次ac!两重循环,max10 000 000居然没超时。。跑了266ms#include<iostream>
using namespace std;
int main ()
{
int i,j,k;
int sum,count;
while (scanf("%d",&k)!=EOF)
{
count=0;
for (i=1;i<=k;i++)
{ sum=0;
for (j=i;j<=k;j++)
{
sum=sum+j;
if (sum>k) break;
if (sum==k) {count++;continue;}
}
}
cout<<count<<endl;
}
return 0;
}
想法很普遍啊。。。。。。
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator