Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pt4.h"
- using namespace std;
- long long toTen(long long a , int k){
- long long kr = 1;
- long long ans = 0;
- while(abs(a)>0){
- ans+= kr *(a%10) ;
- kr *= k;
- a/=10;
- }
- return ans;
- }
- long long toK(long long a , long long k){
- long long ans = 0;
- long long p =1;
- while(a>0){
- ans += p*(a%k);
- a/=k;
- p*=10;
- }
- return ans;
- }
- long long p (long long a , long long b,int k){
- return toK(toTen(a,k)*toTen(b,k),k);
- }
- void Solve()
- {
- Task("TheTri18");
- int X,P,N;
- pt>>X>>N>>P;
- Show(X);
- Show(P);
- Show(N);
- long long ans =X;
- for(int i=0;i<N-1;++i){
- Show((int)p(ans,X,P));
- ans = p(ans,X,P);
- }
- pt<<(int)ans;
- Show((int)toTen(X,P));
- Show((int)toK(toTen(X,P),P));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement