結果
| 問題 |
No.1732 ~サンプルはちゃんと見て!~ 16進数と8進数(2)
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2021-11-07 16:18:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,913 bytes |
| コンパイル時間 | 580 ms |
| コンパイル使用メモリ | 54,656 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-14 02:51:47 |
| 合計ジャッジ時間 | 1,604 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 2 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1732.cc: No.1732 ~サンプルはちゃんと見て!~ 16進数と8進数(2) - yukicoder
*/
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200;
const char S0[] = "ACCACCCCCCCCABACAAFFE"; // 05314531463146314527262527776
const char S1[] = "BBCCCFACAC"; // 013571463726254
const char S2[] = "CCBBA"; // 03145672 = 1100 1100 1011 1011 1010
/* typedef */
typedef vector<int> vi;
/* global variables */
/* subroutines */
void hex2oct(const char s[]) {
vi hs, cs(8, 0);
int l = strlen(s);
for (int i = l - 1; i >= 0; i -= 3) {
int x = 0;
for (int d = 0; d < 3; d++)
x |= (i >= d ? s[i - d] - 'A' + 10 : 0) << (d * 4);
while (x > 0) {
int h = x & 7;
hs.push_back(h);
cs[h]++;
x >>= 3;
}
}
reverse(hs.begin(), hs.end());
printf("%s -> ", S0);
for (auto h: hs) printf("%d", h); putchar(' ');
for (int i = 0; i < 8; i++) printf("%d", cs[i]);
putchar('\n');
}
/* main */
int main() {
/*
Let r=n%3,
r == 0 -> |5,6,7|2,3,6,7|1,3,5,7|2,3,4,5,6,7|
r == 1 -> |0|0|1|2,3,4,5,6,7|
r == 2 -> |0|2,3|1,3,5,7|2,3,4,5,6,7|
*/
//hex2oct(S0); hex2oct(S1); hex2oct(S2);
int tn;
scanf("%d", &tn);
while (tn--) {
int n;
scanf("%d", &n);
int q = n / 3, r = n % 3;
if (r == 0) {
if (q % 7 != 0) { puts("-1"); continue; }
int x = q / 7;
while (x--) printf("%s", S0); putchar('\n');
}
else if (r == 1) {
if ((q * 4 + 2) % 7 != 0) { puts("-1"); continue; }
int x = (n - 10) / 7;
printf("%s", S1);
while (x--) printf("%s", S0); putchar('\n');
}
else { // r == 2
if ((q * 4 + 3) % 7 != 0) { puts("-1"); continue; }
int x = (n - 5) / 7;
printf("%s", S2);
while (x--) printf("%s", S0); putchar('\n');
}
}
return 0;
}
tnakao0123