昨天熄灯前写的,没什么花头的题,注意找找两个序列间的联系应该就差不多了。
- //Accepted 1016 C++ 00:00.00 392K
- #include<stdio.h>
- void solve(int cnt)
- {
- int i,j,p[20];
- for(i = 0; i < cnt; i++)
- scanf("%d",&p[i]);
- i = cnt;
- while(--i) p[i] = p[i] - p[i - 1];
- for(i = 0; i < cnt; i++)
- {
- if(p[i] > 0)
- {
- printf("1");
- if(--p[i] > 0) j = i;
- }
- else
- {
- printf("%d",i - j + 1);
- if(--p[j] == 0)
- while(p[--j] == 0);
- }
- if(i < cnt - 1) printf(" ");
- }
- printf("/n");
- }
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("1016.txt","r",stdin);
- #endif
- int t,n;
- while(scanf("%d",&t) != EOF)
- while(t-- && scanf("%d",&n) != EOF)
- solve(n);
- #ifndef ONLINE_JUDGE
- fclose(stdin);
- #endif
- return 0;
- }