Advertisement
nicuvlad76

Untitled

Nov 26th, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <fstream>
  2. #define N 2005
  3. #define M 100003
  4. using namespace std;
  5. ifstream fin("fractii2.in");
  6. ofstream fout("fractii2.out");
  7. int n, cer;
  8. int dp[N][N];
  9. void Cerinta1()
  10. {
  11. for(int i=1;i<n;i++)
  12. fout<<i<<" ";
  13. fout<<n-1;
  14. }
  15.  
  16. void Cerinta2()
  17. {
  18. dp[2][1]=1;
  19. for(int i=3;i<=n;i++)
  20. for(int j=1;j<=i/2;j++)
  21. {
  22. dp[i][j]=dp[i][j-1]+dp[i-j][(i-j)/2]-dp[i-j][(j+1)/2-1];
  23. if(dp[i][j]<0)dp[i][j]+=M;
  24. if(dp[i][j]>=M) dp[i][j]-=M;
  25. }
  26. fout<<dp[n][n/2]<<"\n";
  27. }
  28. void Afisare()
  29. {
  30. for(int i=1;i<=n;i++)
  31. {
  32. for(int j=1;j<=n;j++)
  33. fout<<dp[i][j]<<" ";
  34. fout<<"\n";
  35. }
  36. }
  37. int main()
  38. {
  39. fin>>cer>>n;
  40. if(cer==1)Cerinta1();
  41. else {
  42. Cerinta2();
  43. ///Afisare();
  44. }
  45. return 0;
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement