文章

35

粉丝

599

获赞

6

访问

295.1k

头像
请问一下怎么改都是66%的原因
P1422 清华大学/厦门大学机试题
发布于2020年4月14日 18:39
阅读数 9.9k

 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(){
	//char s[1050];
	string s;
	int x,y;
	//while(~scanf("%d%d%s",&x,&y,s)){
	while(cin>>x>>y>>s){
	int ans=0;
	//int len=strlen(s);
	int len=s.size();
	for(int i=0;i<len;i++){
		ans=ans*x;
		if(s[i]>='0'&&s[i]<='9')ans+=(s[i]-'0');//等于很关键
		else ans+=(s[i]-'A')+10;
	}
	//char out[105];
		//scanf("%d%d",&n,&x);
	string out;
		//int cnt=0;
		while(ans>0){
			int w=(ans%y);
			if(w>=10){
				out+=(w+'A'-10);//why小a
			}else{
				out+=(w+'0');
			}
		ans/=y;
		}
		reverse(out.begin(), out.end());
//		while(ans>0){
//			int w=(ans%y);
//			if(w<10) out[cnt++]=w+'0';
//			else out[cnt++]=(w-10)+'A';
//			ans/=y;
//		}
//		for(int i=cnt-1;i>=0;i--){
//			//printf("%c",out[i]);
//			cout<<...
登录查看完整内容


登录后发布评论

4 条评论
1035391058 VIP
2021年1月18日 16:56

你看一下提示,是不是没有注意输出的 格式是小写字母。

 

赞(0)
admin SVIP
2020年4月14日 19:01

和正确答案比较一下试试?

赞(0)

chenziyi : 回复 admin: 有个正确答案跟我一毛一样 难受

2020年4月14日 19:18

admin : 回复 admin: 可能是后来数据加强了吧,O(∩_∩)O哈哈~

2020年4月14日 19:43