| ||||||||||
| 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 | |||||||||
扫的,79ms……水过#include <stdio.h>
int main(void)
{
int p;
scanf("%d", &p);
int i = 0;
int j = 0;
int s = 0;
int c = 0;
while(1)
{
if (s < p)
{
s += j + 1;
j = j + 1;
if (j > p)
{
break;
}
} else if (s > p)
{
s -= i + 1;
i = i + 1;
if (i > p)
{
break;
}
} else {
c++;
s += j + 1;
j = j + 1;
if (j > p)
{
break;
}
}
}
printf("%d\n", c);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator