题解 | #进制#
进制
https://www.nowcoder.com/practice/ea6924424f41495794c73e18c43b3a88
#include <bits/stdc++.h> using namespace std; int main() { int p,q; cin >> p >> q; string s; getline(cin,s); // 读掉一个换行! getline(cin,s); int res = 0; for(auto c : s){ res = (res*p + c -'0')%q; } cout << res << endl; return 0; }