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 |
Code#include<iostream> #define Max 10 using namespace std; int res[8100],t[8100],num; void solve(int n) { /* for(int i=2;i<=Max;i++) { res[i-1] = n%i; n /= i; } */ for(int j=1;j<=n;j++) { for(int i=n-1;i>=0;i--) { if(res[i]==0) { t[i] = j; res[i]--; break; } else if(res[i]>0) { res[i]--; } } } } int main() { res[0] = 0; cin>>num; for(int i=1;i<num;i++) { cin>>res[i]; } solve(num); for(int i=0;i<num;i++) { cout<<t[i]<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator