【进制】计算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 @ 2023-04-03 10:48  Tshaxz  阅读(20)  评论(0编辑  收藏  举报
Language: HTML