提交时间:2023-08-21 16:22:50
运行 ID: 99027
#include <iostream> #include <cmath> #include <string> #include <cstring> using namespace std; string a = "ABCDE"; int main() { ios::sync_with_stdio(0); int k,n,l,sum; while(cin >> k >> n >> l) { int w = 1; string str; while(n > 0) { sum += pow(n % 10,w); n /= 10; w++; } while(sum > 0) { int s = sum % l; if(s <= 10) str.push_back((char)s); else str.push_back(a[s-10-1]); sum /= l; } int i = str.length(); while(i >= 0) { cout << str[i] << '\n'; i--; } } }