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 |
吸取前人的经验(附代码)#include <stdio.h> int main () { int n;int a,b;int sum;int flag;int i; scanf("%d",&n); while (n--) { sum=0; scanf ("%d %d",&a,&b); flag=1;i=1; if (a==b) printf("0\n"); else for (;;) { if (flag%2==1) sum=sum+i; else {sum=sum+i;i=i+1;} if (sum>=b-a) {printf("%d\n",flag); break; } flag++; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator