AcWing 3427. 大整数的因子
原题链接
简单
#include <bits/stdc++.h>
using namespace std;
int t, n, m, k, l, r, op, y;
const int siz = 1e2 + 10;
bool flag = false;
class bn {
public:
int l;
char d[siz];
bn operator/(const int& x) {
int cur = 0, rl = 0;
bn res;
for (int i = l - 1; i >= 0; i--) {
cur = cur * 10 + d[i];
if (cur / x)res.d[rl++] = cur / x;
cur %= x;
}
if (cur)res.l = -1;
else res.l = rl;
return res;
}
void print() {
if (l == -1) {
cout << -1 << "\n";
return;
}
for (int i = l - 1; i >= 0; i--) {
cout << (int)d[i];
}
cout << "\n";
}
void set(string st) {
l = st.size();
for (int i = 0; i < l; i++) {
d[i] = st[l - 1 - i] - '0';
}
}
};
bn bn1;
string str;
void solve() {
while (cin >> str&&str!="-1") {
bn1.set(str);
flag = false;
for (int i = 2; i <= 9; i++) {
if ((bn1 / i).l != -1) {
flag = true;
cout << i << " ";
}
}
if (!flag)cout << "none";
cout << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}