社区讨论
老超时……求大神……
P1017[NOIP 2000 提高组] 进制转换参与者 2已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @mi4gas5r
- 此快照首次捕获于
- 2025/11/18 18:48 4 个月前
- 此快照最后确认于
- 2025/11/18 18:48 4 个月前
CPP
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
int a[1000+5];
int main()
{
int top,x,y;
for (;;)
{
scanf("%d%d",&x,&y);
top=0;
while (x!=0)
{
top++;
a[top]=x % y;
x=x / y;
if (a[top]<0)
{
a[top]=a[top]-y;
x++;
}
if (a[top]>=10) a[top]+=55;
}
for (int i=top; i>=1; i--)
{
if (a[i]<10) printf("%d",a[i]);
else
{
char p=(char)a[i];
printf("%c",p);
}
}
printf("(base%d)",y);
printf("\n");
}
return 0;
}
回复
共 5 条回复,欢迎继续交流。
正在加载回复...