Q2 DAA Mock Contest 3

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
1.0 kB
5
Indexable
Never
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define mod 1000000007
#define int long long
using namespace std;

vector<vector<int>> C;

void createPascal() {
    C.resize(4001);
    C[0].assign(1, 1);
    for(int i = 1; i <= 4000; i++) {
        C[i].assign(i + 1, 1);
        for(int j = 1; j < i; j++) {
            C[i][j] = C[i - 1][j - 1];
            C[i][j] = (C[i][j] + C[i - 1][j]) % mod;
        }
    }
}

signed main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int xb, yb, xp, yp; cin >> xb >> yb >> xp >> yp;
    int a, b, c, d;
    int hori = abs(xb - xp);
    int verti = abs(yb - yp);
    createPascal();
        
    a = hori + verti;
    b = C[hori + verti][hori];
    
    if(hori == 0 || verti == 0) c = 0;
    else c = 1;
    
    d = 2 * min(hori, verti);
    if(hori == verti) d--;
    
    cout << a << ' ' << b << ' ' << c << ' ' << d << '\n';
    
    return 0;
}
Leave a Comment