結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー CleyLCleyL
提出日時 2022-08-19 00:29:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,150 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 83,592 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 08:01:45
合計ジャッジ時間 1,822 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int ans[8];
int main(){
    string s;cin>>s;
    reverse(s.begin(),s.end());
    for(int i = 0; s.size() > i; i+=3){
        string x;
        if(i+2 < s.size())x = s.substr(i,3);
        else x = s.substr(i,s.size()-i);
        reverse(x.begin(),x.end());
        string c = "";
        for(int j = 0; x.size() > j; j++){
            int l = x[j]-'A'+10+16;
            string tmp = "";
            while(l){
                tmp.push_back((l%2)+'0');
                l/=2;
            }
            tmp.pop_back();
            reverse(tmp.begin(),tmp.end());
            c += tmp;
        }
        while(c.size()%3)c = "0"+c;
        for(int j = 0; c.size() > j; j+=3){
            ans[(c[j]-'0')*4+(c[j+1]-'0')*2+(c[j+2]-'0')]++;
        }
    }
    int mx = 0;
    vector<int> mxar;
    for(int i = 0; 8 > i; i++){
        if(mx < ans[i]){
            mx = ans[i];
            mxar.clear();mxar.push_back(i);
        }else if(mx == ans[i])mxar.push_back(i);
    }
    for(int i = 0; mxar.size() > i; i++){
        cout << mxar[i] << " \n"[i+1==mxar.size()];
    }
}
0