結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー 👑 platinumplatinum
提出日時 2021-11-05 22:42:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 203,036 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-06 10:40:24
合計ジャッジ時間 3,197 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#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;
}
0