結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー SSRSSSRS
提出日時 2021-11-05 21:23:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 858 bytes
コンパイル時間 1,582 ms
コンパイル使用メモリ 170,616 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-06 09:11:01
合計ジャッジ時間 2,681 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin >> N;
  int L = N.size();
  string S;
  for (int i = 0; i < L; i++){
    int p = N[i] - 'A' + 10;
    for (int j = 3; j >= 0; j--){
      if ((p >> j & 1) == 1){
        S += '1';
      } else {
        S += '0';
      }
    }
  }
  while (S.size() % 3 != 0){
    S = '0' + S;
  }
  int L2 = S.size();
  vector<int> cnt(8, 0);
  for (int i = 0; i < L2; i += 3){
    int p = (S[i] - '0') * 4 + (S[i + 1] - '0') * 2 + (S[i + 2] - '0');
    cnt[p]++;
  }
  int mx = 0;
  for (int i = 0; i < 8; i++){
    mx = max(mx, cnt[i]);
  }
  vector<int> ans;
  for (int i = 0; i < 8; i++){
    if (cnt[i] == mx){
      ans.push_back(i);
    }
  }
  int cnt2 = ans.size();
  for (int i = 0; i < cnt2; i++){
    cout << ans[i];
    if (i < cnt2 - 1){
      cout << ' ';
    }
  }
  cout << endl;
}
0