Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main(void) {
  7. int l;
  8. int w;
  9. int a;
  10. bool works = false;
  11. cin >> l >> w >> a;
  12. int b = l * w - a;
  13. if (w > l) {
  14. swap(w, l);
  15. }
  16. if (b > a) {
  17. swap(a, b);
  18. }
  19. /* for langsomt :(
  20. for (int i = 1; i <= w; i++) {
  21. int tmp = i * l;
  22. if (i * l == b) {
  23. works = true;
  24. break;
  25. }
  26. while (tmp >= b) {
  27. if (tmp % b == 0) {
  28. works = true;
  29. break;
  30. }
  31. tmp -= i;
  32. }
  33. }*/
  34.  
  35. /* Doesn't work :((
  36. if (max(b, l) % min(b, l) == 0) {
  37. works = true;
  38. }*/
  39.  
  40. if ((((l * w) % a) % w) == 0 || (((l * w) % a) % l) == 0) {
  41. cout << 1;
  42. }
  43. else if (works) {
  44. cout << 2;
  45. }
  46. else {
  47. cout << 3;
  48. }
  49.  
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement