結果

問題 No.782 マイナス進数
ユーザー rickythetarickytheta
提出日時 2019-01-11 22:03:39
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 600 bytes
コンパイル時間 2,141 ms
コンパイル使用メモリ 145,508 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-20 06:24:59
合計ジャッジ時間 7,876 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
4,376 KB
testcase_01 AC 28 ms
4,504 KB
testcase_02 AC 17 ms
4,380 KB
testcase_03 AC 24 ms
4,376 KB
testcase_04 AC 30 ms
4,384 KB
testcase_05 AC 19 ms
4,376 KB
testcase_06 AC 18 ms
4,380 KB
testcase_07 AC 50 ms
4,376 KB
testcase_08 AC 22 ms
4,380 KB
testcase_09 AC 16 ms
4,376 KB
testcase_10 AC 17 ms
4,376 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int t,b;
string rev[12525];

int main(){
    scanf("%d%d",&t,&b);
    b = -b;
    REP(v,125252){
        int ev = 0;
        string s;
        int bb = 1;
        int x = v;
        while(x>0){
            int c = x % b;
            x /= b;
            ev += bb * c;
            bb *= -b;
            s = string(1,c+'0') + s;
        }
        if(ev<0 || ev>=12525)continue;
        rev[ev] = s;
    }
    while(t--){
        int n;
        scanf("%d",&n);
        puts(rev[n].c_str());
    }
    return 0;
}
0