Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <vector>
  4. #include <cstdio>
  5. #include <string>
  6. #include <algorithm>
  7. #include <queue>
  8. #include <map>
  9. #include <set>
  10.  
  11. using namespace std;
  12.  
  13. const int MAXN = 1000;
  14.  
  15. int a[MAXN];
  16.  
  17. int main() {
  18.     freopen("input.txt", "r", stdin);
  19.     freopen("output.txt", "w", stdout);
  20.     int p, q, n = 2;
  21.     scanf("%d%d", &p, &q);
  22.     while (p % q != 0) {
  23.         p *= n;
  24.         if (p / q > 0) {
  25.             a[n - 2] = p / q;
  26.             p %= q;
  27.         }
  28.         ++n;
  29.     }
  30.     printf("%d\n", n-1);
  31.     for (int i = 0; i < n - 2; ++i)
  32.         printf("%d\n", a[i]);
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement