提交时间:2023-08-23 19:55:15
运行 ID: 99786
#pragma GCC optimize(1) #pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") # include<iostream> # include<iomanip> # include<algorithm> # include<cmath> # include<cstdio> # include<set> # include<stack> # include<queue> # include<map> # include<string> # include<cstring> # define eps 1e-9 # define fi first # define se second # define ll long long # define int ll // cout<<fixed<<setprecision(n) using namespace std; typedef unsigned long long ull; typedef pair<int,int > PII; const int mod=1e9+7; const int MAX=3e5+10; const int Time=86400; const int X=131; const int inf=0x3f3f3f3f; const double PI = 1e-4; double pai = 3.14159265358979323846; priority_queue<int,vector<int>,less<int>> q; int k,l; string n; char s[MAX]; int change1(int n,string x,int m){ int sum = 0; int p = 0; for(int i = x.size() - 1 ; i >= 0 ; i-- ){ if(isdigit(x[i])) sum+=(x[i] - '0') *pow(n,p) , p++; else sum+=(x[i] - 55 ) *pow(n,p) , p++; } return sum; } void change2(int n,int x,int m){ int t = 0; if(x == 0) { cout<<0<<"\n"; return; } while(x){ int r = x % m; if(x >= 0 && r <= 9) s[t++] = r + '0'; else s[t++] = r+ 55; x /= m; } for(int i = t - 1 ; i >= 0 ; i --) cout<<s[i]; cout<<"\n"; } signed main(){ std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); while(cin >> k >> n >> l){ int x = change1(k,n,10); //cout<<x<<endl; change2(10,x,l); } return 0; }