本地能出但是洛谷显示Too short
查看原帖
本地能出但是洛谷显示Too short
1420936
Sparkle_ovo楼主2024/10/4 10:51
#include<bits/stdc++.h>
#define itn int
#define ll long long
using namespace std;
inline ll read() {
	ll x=0,f=1;
	char ch=getchar();
	while (ch<'0'||ch>'9') {
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9') {
		x=x*10+ch-48;
		ch=getchar();
	}
	return x*f;
}
//vector<char> a;
char a[10000086];
//vector<int> b;
int b[10000086];
int getnum(char ch) {
	if(ch>='0'&&ch<='9')
		return ch-'0';
	else
		return ch-'A'+10;
}
void outnum(int ch) {
	if(ch<10)  printf("%d",ch);
	else  printf("%c",ch+'A'-10);
	return ;
}
int main() {
//	freopen("datain.in","r",stdin); //输入重定向
//	freopen("dataout.out","w",stdout); //输出重定向
	ll cnt=0;
	ll num=0;
	int n;
	cin>>n;
	char gg=getchar();
	gg=getchar();
	while((gg>='0'&&gg<='9')||(gg>='A'&&gg<='F')) {
		a[++cnt]=gg;
		gg=getchar();
	}
	ll weici=1;
	for(int i=1; i<=cnt; i++) {
		int truenum=getnum(a[i]);
		num+=truenum*weici;
		weici*=n;
	}
	int m=read();
	weici=m;
	cnt=0;
	while(num) {
		b[++cnt]=num%weici;
		num/=weici;
//		weici*=m;
	}
	for(itn i=cnt;i>0;i--){
		outnum(b[i]);
	}
//	fclose(stdin);//关闭重定向输入
//	fclose(stdout);//关闭重定向输出
	system("pause");
	return 0;
}
2024/10/4 10:51
加载中...