Advertisement
sve_vash

Untitled

Jul 3rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int gcd(int a, int b) {
  8. while (b != 0) {
  9. int t = b;
  10. b = a % b;
  11. a = t;
  12. }
  13. return a;
  14. }
  15.  
  16. int maxx (int a, int b, int c, bool &isa, bool &isb, bool &isc) {
  17. int res;
  18. if (a > b) {
  19. res = a;
  20. isa = true;
  21. }
  22. else {
  23. res = b;
  24. isb = true;
  25. }
  26.  
  27. if (c > res) {
  28. isa = isb = false;
  29. isc = true;
  30. return c;
  31. }
  32. else
  33. return res;
  34. }
  35.  
  36. void cut (int a, vector <int> &ch) {
  37. int j;
  38. for (int i = 2; i <= a; ++i) {
  39. j = 0;
  40. int h = i;
  41. while ((j < ch.size()) && (h != 1)) {
  42. int g = gcd(ch[j], h);
  43. if ((ch[j] != 1) && (g != 1)) {
  44. ch[j] /= g;
  45. h /= g;
  46. }
  47. ++j;
  48. }
  49. }
  50. }
  51.  
  52. int main() {
  53. ifstream inp("input.txt");
  54. ofstream outp("output.txt");
  55. int x1, y1, z1, x2, y2, z2;
  56.  
  57. inp >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
  58.  
  59. int a = abs(x1 - x2);
  60. int b = abs(y1 - y2);
  61. int c = abs(z1 - z2);
  62. int sum = a + b + c;
  63.  
  64. int i;
  65. vector <int> ch;
  66.  
  67. bool isa = false, isb = false, isc = false;
  68. int m = maxx(a,b,c, isa, isb, isc);
  69.  
  70. for (i = m + 1; i <= sum; ++i) {
  71. ch.push_back(i);
  72. }
  73.  
  74. if (!isa) {
  75. cut(a, ch);
  76. }
  77.  
  78. if (!isb) {
  79. cut(b, ch);
  80. }
  81.  
  82. if (!isc) {
  83. cut(c, ch);
  84. }
  85.  
  86. unsigned long long res = 1;
  87. for (int k = 0; k < ch.size(); k++) {
  88. res = (res * ch[k]) % 1000000007;
  89. }
  90.  
  91. outp << res;
  92. inp.close();
  93. outp.close();
  94. return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement