Advertisement
a53

Untitled

a53
Dec 30th, 2016
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream f ("sir2.in");
  5. ofstream g ("sir2.out");
  6. const int mod = 104729;
  7. int n, k;
  8. int combinari[301]; //n pe orizontal iar k pe verticala
  9.  
  10. inline void maxim()
  11. {
  12. g<<n-k+1<<'\n';
  13. }
  14.  
  15. inline void citeste()
  16. {
  17. f>>n>>k;
  18. maxim();
  19. n--;
  20. k--;
  21. k=min(k,n-k);
  22. }
  23.  
  24. inline void calculeaza()
  25. {
  26. combinari[0] = 1;
  27. for (int i=1; i<=n; i++)
  28. for (int j=k; j>=1; j--)
  29. combinari[j] = (combinari[j] + combinari[j-1]) % mod;
  30. }
  31.  
  32. int main()
  33. {
  34. citeste();
  35. calculeaza();
  36. g<<combinari[k]<<'\n';
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement