.
  • 板块灌水区
  • 楼主User966827
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/8/2 11:47
  • 上次更新2024/8/2 13:13:55
查看原帖
.
966827
User966827楼主2024/8/2 11:47

P1143 60分求助

#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<string>
#include<fstream>
#include<map>
#include<stack>
#include<cwchar>
#include<queue>
#include<vector>
using namespace std;
int st[100000000];
char s[30]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','S','Y','Z'};
int main()
{
	int n;char s[114];char *ed;
	cin>>n>>s;
	long long a=strtol(s,&ed,n);
	int x,cnt=0;
	cin>>x;
	while(1)
	{
		int t;
		t=a%x;
		a=floor(a/x);
		st[++cnt]=t;
		if(a<x)
		{
			break;
		}
	}
	cout<<a;
	for(int i=cnt;i>=1;i--)
	{
		if(st[i]>=10)
		{
			int k=st[i]-10;
			cout<<s[k];
			continue;
		}
		else
		{
			cout<<st[i];
		}
	}
	return 0;
}
2024/8/2 11:47
加载中...