社区讨论

.

灌水区参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@lzc60xp1
此快照首次捕获于
2024/08/02 11:49
2 年前
此快照最后确认于
2024/08/02 13:13
2 年前
查看原帖
P1143 60分求助
CPP
#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;
}

回复

0 条回复,欢迎继续交流。

正在加载回复...