Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // BISMILLAHIR-RAHMANIR-RAHIM
- /*
- ____________________________________
- | |
- | SHANTO_SUST_SWE-19_029 |
- |___________________________________*/
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <stdlib.h>
- #include <time.h>
- #define debug 01
- long long GCD(long long x, long long y)
- {
- long long q, r;
- while(r > 0){
- r = x % y;
- x = y;
- y = r;
- }
- return x;
- }
- int main()
- {
- long long a, b, x;
- long long i, j, k;
- long long gcd, temp;
- while(1){
- scanf("%lld %lld", &a, &b);
- if(a + b == 0) break;
- if(a == b){
- printf("%lld things taken %lld at a time is 1 exactly.\n", a, b);
- continue;
- }
- x = b;
- temp = a - b;
- if(temp < b) b = temp;
- long long n[b], d[b];
- for(i = a, j = b, k = 0; k < b; j--, k++, i--){
- n[k] = i, d[k] = j;
- }
- // i for d, j for n
- for(i = 0; i < b; i++){
- for(j = 0; j < b; j++){
- printf(" \b");
- gcd = GCD(n[j], d[i]);
- n[j] = n[j] / gcd;
- d[i] = d[i] / gcd;
- }
- }
- temp = 1;
- for(i = 0; i < b; i++) {
- temp *= n[i];
- }
- printf("%lld things taken %lld at a time is %lld exactly.\n", a, x, temp);
- }
- return 0;
- }
- //ALHAMDULILLAH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement