a53

necuatie

a53
Mar 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <fstream>
  2. #define MOD 555557
  3. using namespace std;
  4. ifstream f("necuatie.in");
  5. ofstream g("necuatie.out");
  6. long long n,nr,i,j,c[2001][2001];
  7.  
  8. int main()
  9. {
  10. f>>n;
  11. /// Calculez combinarile de i luate cate j, cu i<=n
  12. c[1][0]=1;
  13. c[1][1]=1;
  14. for(i=2;i<=n;++i)
  15. {
  16. c[i][0]=1;
  17. c[i][i]=1;
  18. for(j=1;j<i;++j)
  19. c[i][j]=(c[i-1][j-1]+c[i-1][j])%MOD;
  20. }
  21. /// Aflu numarul solutiilor
  22. nr=1 ;
  23. if(n%2==0)
  24. for(i=0;i<=n-2;i+=2)
  25. nr=(nr+c[n][i]*c[n-i][(n-i)/2])%MOD;
  26. else
  27. for(i=1;i<=n-2;i+=2)
  28. nr=(nr+c[n][i]*c[n-i][(n-i)/2])%MOD;
  29. g<<nr;
  30. return 0;
  31. }
Add Comment
Please, Sign In to add comment