結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー take000take000
提出日時 2022-06-04 20:51:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 811 bytes
コンパイル時間 1,928 ms
コンパイル使用メモリ 205,088 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 02:50:59
合計ジャッジ時間 2,871 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string S;
    cin >> S;

    vector<int> bin;
    for (char &c : S) {
        int d = c - 'A' + 10;
        while (d) {
            bin.push_back(d % 2);
            d /= 2;
        }
    }

    if (bin.size() % 3 != 0) {
        int n = 3 - bin.size() % 3;
        rep(i, n)
            bin.push_back(0);
    }

    vector<int> cnt(8);
    for (int i = 0; i < bin.size(); i += 3) {
        int cur = bin[i] + 2 * bin[i + 1] + 4 * bin[i + 2];
        cnt[cur]++;
    }

    int ma = 0;
    rep(i, 8) ma = max(ma, cnt[i]);

    rep(i, 8) {
        if (cnt[i] == ma) cout << i << " ";
    }
    cout << "\n";

    return 0;
}
0