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 |
简单模拟~~~G++0ms水#include <cstdio> #include <algorithm> using namespace std; int n,m,k,z; int main () { while (scanf("%d",&n)!=EOF) { if(n==0)break; printf("%d ",n); z=1; k=0; m=0; for (int i=1; i<=n; i++) { k++; if(k>z) { z++; k=1; } m=m+z; } printf("%d\n",m); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator