結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー norikamenorikame
提出日時 2021-11-05 22:20:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 867 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 198,124 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 06:09:20
合計ジャッジ時間 2,944 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

int main() {
	string s;
	cin >> s;
	int n = s.length();
	vector<int> cnt(10);
	for (int i=n-1; i>=0; i-=3) {
		string s1 = s.substr(max(0,i-2), i-max(0,i-2)+1);
		int m = s1.length(), val = 0;
		rep(j, m) {
			val *= 16;
			val += 10 + (int)(s1[j]-'A');
		}
		while (val > 0) {
			cnt[val%8]++;
			val /= 8;
		}
	}
	int mval = 0;
	rep(i, 10) mval = max(mval, cnt[i]);
	vector<int> res;
	rep(i, 10) if (cnt[i] == mval) res.push_back(i);
	int m = res.size();
	rep(i, m) printf("%d%c", res[i], (i<m-1?' ':'\n'));
	return 0;
}
0