题解 | #大整数的因子#
大整数的因子
https://www.nowcoder.com/practice/3d6cee12fbf54ea99bb165cbaba5823d
//字符串除法模拟
#include <iostream>
#include <string>
using namespace std;
bool canModk(string s, int k){
    int current = 0;
    for(string::size_type i = 0; i < s.size(); i++){
        current = current * 10 + s[i] - '0';
        if(current >= k){
            s[i] = current / k + '0';
            current %= k;
        }
        else s[i] = '0';
    }
    if(current == 0) return true;
    else return false;
}
int main() {
    string s;
    while(getline(cin ,s)){
        if(s == "-1") break;
        else{
            bool first = true;
            for(int k = 2; k <= 9; k++){
                if(canModk(s, k)){
                    if(first) cout << k;
                    else cout << ' ' << k;
                    first = false;
                }
            }
            if(first) cout << "none";
            cout << endl;
        }
    }
    return 0;
}
// 64 位输出请用 printf("%lld")
 投递大连飞创信息技术有限公司等公司10个岗位
投递大连飞创信息技术有限公司等公司10个岗位
 查看13道真题和解析
查看13道真题和解析