結果
問題 | No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1) |
ユーザー |
![]() |
提出日時 | 2021-11-17 05:23:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,572 bytes |
コンパイル時間 | 1,117 ms |
コンパイル使用メモリ | 105,748 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-21 17:12:10 |
合計ジャッジ時間 | 2,153 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <functional> #include <queue> #include <map> #include <cmath> #include <iomanip> #include <set> #include <cstdio> using namespace std; int main() { string s; cin >> s; string t; for (int i = 0; i < s.size(); i++) { if (s[i] == 'A') t += "1010"; if (s[i] == 'B') t += "1011"; if (s[i] == 'C') t += "1100"; if (s[i] == 'D') t += "1101"; if (s[i] == 'E') t += "1110"; if (s[i] == 'F') t += "1111"; } if (t.size() % 3 == 1) t = "00" + t; else if (t.size() % 3 == 2) t = "0" + t; string ans; for (int i = 0; i < t.size(); i += 3) { string x = t.substr(i , 3); if (x == "000") { ans += '0'; } else if (x == "001") { ans += '1'; } else if (x == "010") { ans += '2'; } else if (x == "011") { ans += '3'; } else if (x == "100") { ans += '4'; } else if (x == "101") { ans += '5'; } else if (x == "110") { ans += '6'; } else if (x == "111") { ans += '7'; } } vector<int> cnt(8 , 0); for (int i = 0; i < ans.size(); i++) { cnt[ans[i] - '0']++; } vector<pair<int,int> > p(8); for (int i = 0; i < 8; i++) { p[i] = make_pair(cnt[i] , -i); } sort(p.begin() , p.end()); reverse(p.begin() , p.end()); for (int i = 0; i < 8; i++) { if (i == 0) { cout << -p[i].second; } else { if (p[i].first != p[i - 1].first) { cout << endl; break; } else { cout << -p[i].second; } } cout << " "; } return 0; }