【进制】计算B进制(秦九韶算法)

计算B进制的值(秦九韶算法)

image

4945. 比大小

#include <iostream>
#include <cstring>

using namespace std;

typedef long long LL;

LL get()
{
    LL res = 0;
    int n, b;
    cin >> n >> b;
    while (n -- )
    {
        int x;
        cin >> x;
        res = res * b + x; // 用res表示当前的值(同时也可表示上一位的值)
    }
    return res;
}

int main()
{
    LL res1 = get(), res2 = get();
    if (res1 > res2) cout << ">" << endl;
    else if (res1 < res2) cout << "<" << endl;
    else cout << "=" << endl;
    return 0;
}
posted @   Tshaxz  阅读(20)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
Language: HTML
点击右上角即可分享
微信分享提示