QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#331443#7049. Base62nickolessAC ✓1ms3908kbC++141.9kb2024-02-18 09:44:422024-02-18 09:44:42

Judging History

你现在查看的是最新测评结果

  • [2024-02-18 09:44:42]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3908kb
  • [2024-02-18 09:44:42]
  • 提交

answer

#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int x,y;
string z;
map<char,int> mp1;
map<int,char> mp2;

void print(vector<int> t){
	for(auto it=t.rbegin();it!=t.rend();it++)cout<<mp2[*it];
	puts("");
	return;
}
vector<int> g(int x){
	vector<int> a;
	do{
		a.push_back(x%10);
		x/=10;
	}while(x);
	return a;
}
vector<int> operator+(vector<int> a,vector<int> b){
	int n=max(a.size(),b.size());
	vector<int> c(n,0);
	for(int i=0;i<n;i++)
		c[i]=((i<a.size())?a[i]:0)+((i<b.size())?b[i]:0);
	int ct=0;
	for(int i=0;i<n;i++){
		c[i]+=ct;
		ct=c[i]/10;
		c[i]%=10;
	}
	while(ct){
		c.push_back(ct%10);
		ct/=10;
	}
	return c;
}
vector<int> operator*(vector<int> a,int b){
	for(int i=0;i<a.size();i++)
		a[i]*=b;
	int ct=0;
	for(int i=0;i<a.size();i++){
		a[i]+=ct;
		ct=a[i]/10;
		a[i]%=10;
	}
	while(ct){
		a.push_back(ct%10);
		ct/=10;
	}
	return a;
}
pair<vector<int>,int> operator/(vector<int> a,int b){
	vector<int> c;
	int tmp=0;
	for(int i=a.size()-1;i>=0;i--){
		tmp*=10;
		tmp+=a[i];
		c.push_back(tmp/b);
		tmp%=b;
	}
	reverse(c.begin(),c.end());
	while(c.size()>1 && c.back()==0)c.pop_back();
	return make_pair(c,tmp);
}

vector<int> to10(string s,int p){
	vector<int> t(g(0));
	for(auto x:s){
		t=t*p;
		t=t+g(mp1[x]);
	}
	return t;
}
vector<int> toy(vector<int> t,int y){
	vector<int> a;
	do{
		auto x=t/y;
		t=x.first;
		a.push_back(x.second);
	}while(t!=g(0));
	return a;
}

int main(){
	for(int i=0;i<=9;i++){
		mp1['0'+i]=i;
		mp2[i]='0'+i;
	}
	for(int i=0;i<26;i++){
		mp1['A'+i]=10+i;
		mp2[10+i]='A'+i;
	}
	for(int i=0;i<26;i++){
		mp1['a'+i]=36+i;
		mp2[36+i]='a'+i;
	}
	
//	auto xx=g(23)/114514;
//	print(xx.first);
//	cout<<xx.second<<endl;
	
	cin>>x>>y>>z;
	
	print(toy(to10(z,x),y));
	
	return 0;
}
/*
16 2 FB

62 2 0
*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3808kb

input:

16 2 FB

output:

11111011

result:

ok single line: '11111011'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

62 2 abcdefghiz

output:

11011100000100010111110010010110011111001001100011010010001

result:

ok single line: '11011100000100010111110010010110011111001001100011010010001'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

10 16 1234567890123456789012345678901234567890

output:

3A0C92075C0DBF3B8ACBC5F96CE3F0AD2

result:

ok single line: '3A0C92075C0DBF3B8ACBC5F96CE3F0AD2'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

16 35 3A0C92075C0DBF3B8ACBC5F96CE3F0AD2

output:

333YMHOUE8JPLT7OX6K9FYCQ8A

result:

ok single line: '333YMHOUE8JPLT7OX6K9FYCQ8A'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

35 23 333YMHOUE8JPLT7OX6K9FYCQ8A

output:

946B9AA02MI37E3D3MMJ4G7BL2F05

result:

ok single line: '946B9AA02MI37E3D3MMJ4G7BL2F05'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

23 49 946B9AA02MI37E3D3MMJ4G7BL2F05

output:

1VbDkSIMJL3JjRgAdlUfcaWj

result:

ok single line: '1VbDkSIMJL3JjRgAdlUfcaWj'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

61 5 dl9MDSWqwHjDnToKcsWE1S

output:

42104444441001414401221302402201233340311104212022133030

result:

ok single line: '42104444441001414401221302402201233340311104212022133030'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

5 10 42104444441001414401221302402201233340311104212022133030

output:

1234567890123456789012345678901234567890

result:

ok single line: '1234567890123456789012345678901234567890'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

62 10 123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

output:

361097996547231939420324315862125604148156665886431480862914942937732101183106158332978897913678986703118641

result:

ok single line: '361097996547231939420324315862...6158332978897913678986703118641'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3872kb

input:

10 62 361097996547231939420324315862125604148156665886431480862914942937732101183106158332978897913678986703118641

output:

123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

result:

ok single line: '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

62 2 1000000000000

output:

101011101110010101110010000011101110100000110000011010000001000000000000

result:

ok single line: '101011101110010101110010000011...0110000011010000001000000000000'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

62 2 0

output:

0

result:

ok single line: '0'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3908kb

input:

62 2 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

output:

101101010111011101011010100010010111100101010100101110001000001101101111000000111101111101011101101111010000100001111110100110110110001101010010101000000011010000100100110101000110110010001110001011001111001100001101010010001111001100110100110110111101001010111100010010011111110111111000010011110010...

result:

ok single line: '101101010111011101011010100010...1111111111111111111111111111111'