Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
1.2 kB
2
Indexable
Never
#include <stdio.h>

int main()
{
unsigned long long int n,r,a,b;
scanf("%llu %llu %llu %llu",&n,&r,&a,&b);


unsigned long long int c = 1,d,k,d1 = 1,d2 = 1,d3 = 1,d4 = 1;
unsigned long long int k1,k2,k3,k4;
if(r==3)
{
    for (k1 = 0; k1 < a; k1++) {
        d1 *= 1;
    }
        for (k2 = 0; k2 < b; k2++) {
        d2 *= 6;
    }
        d = d1*d2;
}
else
{

    for (k3 = 0; k3 < a; k3++) {
            d3 *= 3;
    }
        for (k4 = 0; k4 < b; k4++) {
            d4 *= 4;
    }
    d = d3*d4;
}

for (k = 0; k < n; k++) {
    c *= 7;
}

unsigned long long int g,h;
if(a>b)
{
    g = a + 1;
    h = b;
}
    else if (a<b)
    {
        g = b + 1;
        h = a;
    }
        else
        {   
            g = a + 1;
            h = a;
        }


unsigned long long int i,t=1;
for (i=g;i<=n;i++){
    t = i*t;
}
unsigned long long int j,s=1;
    for (j=1;j<=h;j++){
        s = j*s;
    }
    c = c*s;
    d = d*t;

unsigned long long int e,f;
e = c;
f = d;
unsigned long long int temp;
while (f != 0) {
    temp = f;
    f = e % f;
    e = temp;
}
unsigned long long int D,C;
D = d/e;
C = c/e;

printf("%llu/%llu",D,C);

return 0;
}