求助,超时两个!!!
  • 板块题目总版
  • 楼主biyaxin
  • 当前回复7
  • 已保存回复7
  • 发布时间2023/10/13 20:19
  • 上次更新2023/11/2 14:04:22
查看原帖
求助,超时两个!!!
1121376
biyaxin楼主2023/10/13 20:19

以下为代码部分


#include<bits/stdc++.h>
#include<stack>
using namespace std;
stack<char>s; 
int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n,R;
	cin>>n>>R;
	int q=n;
	cout<<q<<"=";
	while(n){
		int m=n%R;
		if(m<0){
			m-=R;
			n+=R;
		}
		if(m>=10){
			m=m+'A'-10;
		}
		else{
			m=m+'0';//?
			s.push(m);
			n/=R;
		}
	}
	while(!s.empty()){
		char x;
		x=s.top();
		s.pop();
		cout<<x;
	}
	cout<<"(base"<<R<<")";
	
	return 0;
} 
2023/10/13 20:19
加载中...