Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <vector>
- #include <cstdio>
- #include <string>
- #include <algorithm>
- #include <queue>
- #include <map>
- #include <set>
- using namespace std;
- const int MAXN = 1000;
- int a[MAXN];
- int main() {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- int p, q, n = 2;
- scanf("%d%d", &p, &q);
- while (p % q != 0) {
- p *= n;
- if (p / q > 0) {
- a[n - 2] = p / q;
- p %= q;
- }
- ++n;
- }
- printf("%d\n", n-1);
- for (int i = 0; i < n - 2; ++i)
- printf("%d\n", a[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement