Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<vector>
  4. #include<algorithm>
  5. #include<stack>
  6. using namespace std;
  7. int main()
  8. {
  9. long long int k,n,m;
  10. cin>>k>>n>>m;
  11. if(k == 0 && n==0 && m==0)
  12. {
  13. cout<<1;
  14. return 0;
  15. }
  16. if(k == 0)
  17. {
  18. if((n+1)*(m+1) == 1)
  19. cout<<1;
  20. else
  21. cout<<1<<"/"<<(n+1)*(m+1)-1;
  22. return 0;
  23. }
  24. int positive = 0;
  25. int negative = 0;
  26. for(int i = 0;i<=n;i++)
  27. {
  28. for(int j = 0;j<=m;j++)
  29. {
  30. if((k - (i*2+j*3)) == 0)
  31. positive++;
  32. else
  33. negative++;
  34. }
  35. }
  36. if(positive % (positive+negative) == 0)
  37. cout<<positive/(positive+negative);
  38. else
  39. cout<<positive<<"/"<<positive+negative;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement