結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー yansi819yansi819
提出日時 2024-03-21 10:36:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,107 bytes
コンパイル時間 5,087 ms
コンパイル使用メモリ 279,556 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-21 10:36:34
合計ジャッジ時間 6,834 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

string N, B, O;
map<char, string> mp1 = {{'A', "1010"}, {'B', "1011"}, {'C', "1100"}, {'D', "1101"}, {'E', "1110"}, {'F', "1111"}};
map<string, char> mp2 = {{"000", '0'}, {"001", '1'}, {"010", '2'}, {"011", '3'}, {"100", '4'}, 
                        {"101", '5'}, {"110", '6'}, {"111", '7'}};
int cnt[8];

int main() {
  cin >> N;
  for (int i = 0; i < N.size(); i++) {
    B += mp1[N[i]];
  }
  int tail = B.size(), pos = 0;
  for (int i = B.size() - 1; i >= 0; i--) {
    pos++;
    if (i == 0 || pos % 3 == 0) {
      string B1 = "00" + B.substr(i, tail - i);
      O += mp2[B1.substr(B1.size() - 3)];
      tail = i;
    }
  }
  reverse(O.begin(), O.end());
  for (int i = 0; i < O.size(); i++) {
    cnt[O[i] - '0']++;
  }
  int maxe = *max_element(cnt, cnt + 8);
  vector<int> ans;
  for (int i = 0; i < 8; i++) {
    if (cnt[i] == maxe) ans.push_back(i);
  }
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " \n"[i == ans.size() - 1];
  return 0;
}
0