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;
- long long i, j, k;
- long long gcd, temp;
- while(1){
- scanf("%lld %lld", &a, &b);
- if(a + b == 0) break;
- 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++){
- printf("kaj hoy-01\n");
- for(j = 0; j < b; j++){
- printf("kaj hoy-02\n");
- if(n[j] == 1) continue;
- if(d[i] == 1) break;
- if(n[j] % d[i] == 0){
- n[j] = n[i] / d[i];
- d[i] = 1;
- break;
- }
- gcd = GCD(n[j], d[i]);
- printf("kaj hoy-03\n");
- 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 %lld exactly.\n", a, b, temp);
- }
- return 0;
- }
- //ALHAMDULILLAH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement