Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- using namespace std;
- int gcd(int a, int b) {
- while (b != 0) {
- int t = b;
- b = a % b;
- a = t;
- }
- return a;
- }
- int maxx (int a, int b, int c, bool &isa, bool &isb, bool &isc) {
- int res;
- if (a > b) {
- res = a;
- isa = true;
- }
- else {
- res = b;
- isb = true;
- }
- if (c > res) {
- isa = isb = false;
- isc = true;
- return c;
- }
- else
- return res;
- }
- void cut (int a, vector <int> &ch) {
- int j;
- for (int i = 2; i <= a; ++i) {
- j = 0;
- int h = i;
- while ((j < ch.size()) && (h != 1)) {
- int g = gcd(ch[j], h);
- if ((ch[j] != 1) && (g != 1)) {
- ch[j] /= g;
- h /= g;
- }
- ++j;
- }
- }
- }
- int main() {
- ifstream inp("input.txt");
- ofstream outp("output.txt");
- int x1, y1, z1, x2, y2, z2;
- inp >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
- int a = abs(x1 - x2);
- int b = abs(y1 - y2);
- int c = abs(z1 - z2);
- int sum = a + b + c;
- int i;
- vector <int> ch;
- bool isa = false, isb = false, isc = false;
- int m = maxx(a,b,c, isa, isb, isc);
- for (i = m + 1; i <= sum; ++i) {
- ch.push_back(i);
- }
- if (!isa) {
- cut(a, ch);
- }
- if (!isb) {
- cut(b, ch);
- }
- if (!isc) {
- cut(c, ch);
- }
- unsigned long long res = 1;
- for (int k = 0; k < ch.size(); k++) {
- res = (res * ch[k]) % 1000000007;
- }
- outp << res;
- inp.close();
- outp.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement