結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 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;

string s;
long long t;
pair<int, int> a[8];

int main()
{
	cin >> s;

	for (int i = 0; i < 8; i++)
		a[i].second = - i;

	int n = s.size();

	for (int i = 0; i < n; i++) {
		int u = (s[n - 1 - i] - 'A' + 10);

		if (i % 3 == 1)
			u *= 2;
		else if (i % 3 == 2)
			u *= 4;

		u += t;
		a[u % 8].first++;
		t = u / 8;

		if (i % 3 == 2) {
			a[t % 8].first++;
			t /= 8;
		}
	}

	while (t > 0) {
		a[t % 8].first++;
		t /= 8;
	}

	sort(a, a + 8, greater<pair<int, int>>());

	int w = a[0].first;

	for (int i = 0; i < 8; i++) {
		cout << -a[i].second;

		if (i < 7 && a[i].first == a[i + 1].first)
			cout << " ";
		else {
			cout << endl;
			break;
		}
	}
}
0