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 |
根本没想那么多,打个表,0MS过……#include<iostream> #include<stdlib.h> using namespace std; long coin[10001]; int main() { int i,k,j; long n,ans; k=1;j=0; for (i=1;i<=10000;i++) { if (j<k) {coin[i]=k;j++;} if (j>=k) {j=0;k++;} } while(cin>>n&&n!=0) { ans=0; for (j=1;j<=n;j++) ans+=coin[j]; cout<<n<<" "<<ans<<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