Uva 10784 - Diagonal

来源:互联网 发布:sql2000数据库无项目 编辑:程序博客网 时间:2024/06/14 08:19

又一道水题

找到关系

nC2-n

然后就是不等式了=.=

1Y

#include<stdio.h>#include<math.h>#define LL long longint main(){LL n;int z=0;while(scanf("%lld",&n)!=EOF&&n){LL res=(3+sqrt(8*n+9))/2;while(res*(res-1)/2-res<n)res++;printf("Case %d: ",++z);printf("%lld\n",res);}return 0;}