Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. // Example program
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. /*long long gcd(long long a, long long b){
  8. long long r = 0;
  9. while (b != 0)
  10. {
  11. r = a % b;
  12. a = b;
  13. b = r;
  14. }
  15. return a;
  16. }
  17. **/
  18. int main()
  19. {
  20. long long n, a, b, count = 0;
  21. cin >> n >> a >> b;
  22. long long n2 = 0, n3 = 0;
  23.  
  24. if (n % 2 == 0) n2 = n/2;
  25. else {
  26. n3 = 1;
  27. n -= 3;
  28. n2 = n/2;
  29. }
  30.  
  31.  
  32. //n2 - step 3; n3 + step 2
  33. while (n3 * n2 >= 0){
  34. if (n2 <= a && n3 <= b) count++;
  35. n2 -= 3;
  36. n3 += 2;
  37. }
  38.  
  39.  
  40. if (count == (a + 1) * (b + 1)) cout << 1;
  41. else if(count == 0) cout << 0;
  42. else {
  43. long long g = 1;//gcd(count, (a+1)*(b+1));
  44. cout << count / g << '/' << (a + 1) * (b + 1) / g;
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement