結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー ぷらぷら
提出日時 2021-11-25 01:49:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 960 bytes
コンパイル時間 2,286 ms
コンパイル使用メモリ 210,028 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 19:17:03
合計ジャッジ時間 3,709 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

string Calc(char c) {
    int n = 10+(c-'A');
    string ans = "";
    for(int i = 0; i < 4; i++) {
        ans += (char)('0'+n%2);
        n >>= 1;
    }
    reverse(ans.begin(),ans.end());
    return ans;
}

int calc(string s) {
    int res = 0;
    res += (s[0]-'0')*4;
    res += (s[1]-'0')*2;
    res += (s[2]-'0')*1;
    return res;
}

int main() {
    string N;
    cin >> N;
    string S = "";
    for(int i = 0; i < N.size(); i++) {
        S += Calc(N[i]);
    }
    S = string((3-S.size()%3)%3,'0')+S;
    map<int,int>tmp;
    int mx = 0;
    for(int i = 0; i < S.size(); i += 3) {
        tmp[calc(S.substr(i,3))]++;
        mx = max(mx,tmp[calc(S.substr(i,3))]);
    }
    vector<int>ans;
    for(auto i:tmp) {
        if(i.second == mx) {
            ans.push_back(i.first);
        }
    }
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i] << ((i+1 == ans.size())?"\n":" ");
    }
}
0