标签:space using main mes class cto car 问题 ace
基本思想:
无;
关键点:
无;
#include<iostream> #include<vector> #include<algorithm> #include<math.h> #include<string> using namespace std; void mutlip(string &s, int n) { int carry = 0; for (int i = 0; i < s.size(); i++) { int temp = (s[i] - ‘0‘)*n + carry; s[i] = temp % 10+‘0‘; carry = temp / 10; } while (carry != 0) { s += char(carry % 10+‘0‘); carry /= 10; } } int devide(string &s, int n, int r) { string res = s; for (int i = s.size() - 1; i >= 0; i--) { int temp = (s[i] - ‘0‘) + r * 10; res[i] = char(temp / n + ‘0‘); r = temp % n; } while (res.size() > 0 && res[res.size() - 1] == ‘0‘) res.pop_back(); s = res; return r; } int main() { int a, b; while (cin >> a >> b) { string jc = to_string(a); for (int i = a - 1; i > 0; i--) { mutlip(jc, i); } int cnt = 0; while (devide(jc, b, 0) == 0) { cnt++; } cout << cnt << endl; } }
标签:space using main mes class cto car 问题 ace
原文地址:https://www.cnblogs.com/songlinxuan/p/12466273.html