⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1334.cpp

📁 ZOJ 动态规划算法题目入门与提高 源代码
💻 CPP
字号:
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    //ifstream cin("in.txt");
    string s;
    int a,b;
    while(cin>>s>>a>>b)
    {
        int t=0,i=0;
        while(t<300000000&&i<s.length())
        {
            if(s[i]>='0'&&s[i]<='9') t=t*a+(s[i]-'0');
            else t=t*a+(s[i]-'A'+10);
            i++;            
        }
       
        if(t>=300000000)
           { cout<<" ERROR\n";continue;}
        string temp="";
        while(t)
        {
            int x=t%b;
            if(x>9) temp+=('A'+x-10);
            else temp+=('0'+x);
            t/=b;
        }
        reverse(temp.begin(),temp.end());
        if(temp.length()<=7) {cout.width(6);cout<<temp<<'\n';}
        else {cout<<" ERROR\n";}       
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -