結果
| 問題 |
No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
|
| コンテスト | |
| ユーザー |
platinum
|
| 提出日時 | 2021-11-05 22:42:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| コード長 | 965 bytes |
| コンパイル時間 | 4,035 ms |
| コンパイル使用メモリ | 199,624 KB |
| 最終ジャッジ日時 | 2025-01-25 12:37:39 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using LL = long long;
using P = pair<int,int>;
using vv = vector<vector<int>>;
const int INF = (int)1e9;
const LL LINF = (LL)1e18;
int main(){
string S;
cin >> S;
reverse(S.begin(), S.end());
int N = S.size();
int r = (3 - N % 3) % 3;
rep(i,r) S += '0';
N = S.size();
vector<int> cnt(8);
for(int i = 0; i < N; i += 3){
string T = S.substr(i, 3);
int res = 0;
rep(j,3){
if(T[j] == '0') break;
int base = 1;
rep(k,j) base *= 16;
res += base * (T[j] - 'A' + 10);
}
for(int j = 3; j >= 0; j--){
int base = 1;
rep(k,j) base *= 8;
int q = res / base;
if(i < N - 3 or q > 0) cnt[q]++;
res -= base * q;
}
}
int val = 0;
rep(i,8) val = max(val, cnt[i]);
vector<int> ans;
rep(i,8) if(cnt[i] == val) ans.emplace_back(i);
int siz = ans.size();
rep(i,siz-1) cout << ans[i] << " ";
cout << ans[siz-1] << endl;
return 0;
}
platinum