fork download
  1. #pragma GCC optimize("Ofast,fast-math,unroll-loops,no-stack-protector")
  2. #include <stdio.h>
  3. #define N 3100<<3
  4. char buf[N],*p1=buf,*p2=buf,buf2[N],*p3=buf2,*p4=buf2,c;
  5. #define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,N,stdin),p1==p2)?EOF:*p1++)
  6. void inline pc(char i){if(p3==p4){puts(buf2);p3=buf2;}*p3++=i;}
  7. int n,k,j;
  8. int main(){
  9. p4+=N;
  10. for(;(c=gc())!=EOF;){
  11. for(n=0;c!='\n';n+=c-'0',c=gc())n*=10;
  12. if(n==1){pc('0');c=gc();}
  13. else{
  14. while(--n){
  15. for(k=0;c=gc(),c!=' ';k+=c-'0')k*=10;
  16. k*=n;for(j=10;j<=k;)j*=10;
  17. for(j/=10;j;k%=j,j/=10)pc((k/j)+'0');
  18. pc(' ');
  19. }
  20. }
  21. for(;c!='\n'&&c!=EOF;)c=gc();pc('\n');
  22. }
  23. if(p3!=buf2)puts(buf2);
  24. return 0;
  25. }
Success #stdin #stdout 0s 5540KB
stdin
3
1 2 1
3
1 2 1
stdout
2 2 
2 2