hdu 1874

简介:

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1877

#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main()
{
    int a1,b,m,n;
    while(~scanf("%d",&m),m)
    {
        scanf("%d%d",&a1,&b);
        n=a1+b;
        if(n==0)
            cout<<0;
        else if(n>0)
        {
            int i=0;
            while(n>0)
            {
              i++;
              a[i]=n%m;
              n=n/m;
            }
            for(int j=i;j>=1;j--)
               printf("%d",a[j]);
        }
        else
        {
            int i=0;
            cout<<"-";
            n=-n;
            while(n>0)
            {
              i++;
              a[i]=n%m;
              n=n/m;
            }
            for(int j=i;j>=1;j--)
                printf("%d",a[j]);
        }
        cout<<endl;
    }
    return 0;
}
目录
相关文章
|
2月前
|
Java 测试技术
hdu 1228 A + B
hdu 1228 A + B
18 0
|
机器学习/深度学习 Java 算法
hdu 1856 More is better
点击hdu 1856思路: 思路: 离散化+并查集 分析: 1 点数最多为10^7,但是边数最多10^5,所以我们必须采用离散化,然后利用带权并查集的思想,rank[x]表示的是以x为根节点的集合的元素个数 2 这一题主要注意的就是当...
811 0