Advertisement
a53

turnuri2

a53
Feb 11th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <cstdio>
  2. using namespace std;
  3. FILE *fin=fopen("turnuri.in","r");
  4. FILE *fou=fopen("turnuri.out","w");
  5. int n,a[300],r[300];
  6. long double res=0;
  7.  
  8. void read()
  9. {
  10. int i;
  11. n=0;
  12. while (1)
  13. {
  14. fscanf(fin,"%d",&i);
  15. if (!i) break;
  16. a[n++]=i;
  17. }
  18. }
  19.  
  20. int modn(int x,int n)
  21. {
  22. while(x<0)
  23. x+=n;
  24. return x%n;
  25. }
  26.  
  27. void solve()
  28. {
  29. int i,j,k,l;
  30. long double count[500],c2[500];
  31. for(i=0;i<500;++i)
  32. count[i]=0;
  33. if(a[0]%2==0)
  34. count[0]=1;
  35. else
  36. count[1]=1;
  37. for(l=1;l<n;++l)
  38. {
  39. for(j=0;j<n*2;++j)
  40. c2[j]=0;
  41. k=a[l];
  42. for(i=0;i<k;++i)
  43. for(j=0;j<2*l;++j)
  44. if(i!=0||j!=0)
  45. c2[modn(j+k-2*i,2*(l+1))]+=count[j];
  46. res=0;
  47. for(j=0;j<n*2;++j)
  48. res+=count[j]=c2[j];
  49. }
  50. }
  51.  
  52. void write()
  53. {
  54. fprintf(fou,"%.0lf\n",(double)res);
  55. }
  56.  
  57. int main(int argc,char *argv[])
  58. {
  59. read();
  60. solve();
  61. write();
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement