a53

pdl

a53
Jun 1st, 2019
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <fstream>
  2. #define NMAX 2005
  3. #define MOD 3000017
  4. using namespace std;
  5. int N,i,j;
  6. unsigned long long P[NMAX+5],cnt,PC[NMAX+5],Sol;
  7.  
  8. int mod(unsigned long a,int m)
  9. {
  10. a%=m;
  11. if(a<0)
  12. a+=m;
  13. return a;
  14. }
  15.  
  16. unsigned long long partitions_increasing(int n)
  17. {
  18. PC[0]=1;
  19. for(i=1;i<=n;++i)
  20. for(j=n;j>=i;--j)
  21. PC[j]=mod(PC[j]+PC[j-i],MOD);
  22. return PC[n];
  23. }
  24.  
  25. unsigned long long compute_partitions1(int n)
  26. {
  27. P[0]=1;
  28. for(int i=1;i<=n;++i)
  29. for(int j=i;j<=n;++j)
  30. P[j]=mod(P[j]+P[j-i],MOD);
  31. return P[n];
  32. }
  33.  
  34. int main()
  35. {
  36. ifstream f("pdl.in");
  37. f>>N;
  38. f.close();
  39. compute_partitions1(N);
  40. partitions_increasing(N);
  41. Sol=(P[N]-PC[N]+MOD)%MOD;
  42. ofstream g("pdl.out");
  43. g<<Sol;
  44. g.close();
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment