結果
| 問題 |
No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2021-11-05 21:23:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 858 bytes |
| コンパイル時間 | 1,742 ms |
| コンパイル使用メモリ | 172,860 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-06 12:06:30 |
| 合計ジャッジ時間 | 2,586 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
#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;
}
SSRS