0分,肉眼输出和答案一致但没过,错误原因是答案太短?
查看原帖
0分,肉眼输出和答案一致但没过,错误原因是答案太短?
763998
switch_on楼主2022/11/22 19:17

翻了一下本题的讨论区,看见其他相同情况的都是因为读入的时候多读了\r,但我的加上判断\r不知为何会超时,有无dalao救一下

#include<bits/stdc++.h> 
using namespace std;

int m,n,nextt;
int awa=0,len=0;
int qwq[40];

int main(){
	cin>>m;
	nextt=getchar();
	while((nextt=getchar())!=('\n')){
		awa*=m;
		if(nextt>='A'&&nextt<='F'){
			nextt-=('A'-10);
		}
		else nextt-=48;
		awa+=nextt;
		//cout<<nextt<<" "<<awa<<endl;
	}
	//cout<<awa;
	
	cin>>n;
	while(awa){
		qwq[++len]=awa%n;
		awa/=n;
	}
	
	while(len){
		if(qwq[len]>=10){
			char a='A'+qwq[len]-10;
			cout<<a;
		}
		else cout<<qwq[len];
		len--;
	}
	
	return 0;
}
2022/11/22 19:17
加载中...