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 <iostream> using namespace std; int main() { int i,j,t,n; int g_left_sum[21],left_sum[21],result_sum[21]; left_sum[0]=0;g_left_sum[0]=1; cin>>t; while (t--) { cin>>n; for (i=1;i<=n;i++) { cin>>left_sum[i]; g_left_sum[i]=left_sum[i]-left_sum[i-1]; } for (i=1;i<=n;i++) { for (j=i;j>=0;j--) { if(.......)//版权问题,此处被省略~ { g_left_sum[j]--; result_sum[i]=i-j+1; break; } } } cout<<result_sum[1]; for (i=2;i<=n;i++) cout<<" "<<result_sum[i]; cout<<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