結果
| 問題 |
No.1732 ~サンプルはちゃんと見て!~ 16進数と8進数(2)
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2021-11-05 23:42:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,141 bytes |
| コンパイル時間 | 1,490 ms |
| コンパイル使用メモリ | 125,696 KB |
| 最終ジャッジ日時 | 2025-01-25 13:57:10 |
|
ジャッジサーバーID (参考情報) |
judge8 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘std::string solve(int)’:
main.cpp:46:1: warning: no return statement in function returning non-void [-Wreturn-type]
46 | }
| ^
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
if(v.empty()) {
cout << endl;
return;
}
for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
cout << v.back() << endl;
}
string solve(int n){
}
vector<int> pow16 = {0, 16, 256};
vector<int> pow8 = {0, 8, 64, 512};
string as_base_8(int n){
string ans;
while(n){
ans += (n%8)+'0';
n /= 8;
}
reverse(ans.begin(), ans.end());
return ans;
}
string as_base_16(int n){
string ans;
while(n){
int r = n%16;
if(r <= 9) ans += r+'0';
else ans += (r-10)+'A';
n /= 16;
}
reverse(ans.begin(), ans.end());
return ans;
}
string base8_to_base16(string s){
int x = 0;
for(char c: s){
x = x*8+(c-'0');
}
cout << s << ' ' << x << ' ' << as_base_16(x) << endl;
return as_base_16(x);
}
map<string, string> mp;
void test(){
for(int x = 0; x < 16*16*16; x++) {
auto b8 = as_base_8(x);
auto b16 = as_base_16(x);
bool ok = true;
for(char c: b16){
if(isdigit(c)) ok = false;
}
if(ok){
mp[b16] = b8;
}
}
}
int calc_len(int i){
int len = (i/3)*4;
if(i%3 == 1) len += 2;
if(i%3 == 2) len += 3;
return len;
}
void f(){
string s = "1234567";
do{
auto t = base8_to_base16(s);
bool ok = true;
for(char c: t){
if(isdigit(c)) ok = false;
}
if(ok){
cout << t << endl;
break;
}
}while(next_permutation(s.begin(), s.end()));
}
string s7 = "ABDCC";
string s14 = "BBCCCFACAC";
string s28 = "ACCACCCCCCCCABACAAFFE";
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int t; cin >> t;
while(t--){
int n; cin >> n;
int len = calc_len(n);
if(len%7 != 0 || len%28 == 21){
cout << -1 << endl;
continue;
}
string ans;
for(int i = 0; i < len/28; i++) ans += s28;
if(len%28 == 7) ans += s7;
if(len%28 == 14) ans += s14;
cout << ans << endl;
}
}
milanis48663220