結果
| 問題 |
No.2929 Miracle Branch
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-10-14 15:50:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 995 bytes |
| コンパイル時間 | 475 ms |
| コンパイル使用メモリ | 57,616 KB |
| 最終ジャッジ日時 | 2025-02-24 19:31:44 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%lld", &x);
| ~~~~~^~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 2929.cc: No.2929 Miracle Branch - yukicoder
*/
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200000;
/* typedef */
using ll = long long;
using vi = vector<int>;
/* global variables */
/* subroutines */
/* main */
int main() {
ll x;
scanf("%lld", &x);
vi vs;
if (x <= 4) vs.push_back(x);
else {
for (int i = 2; x > 1 && i <= MAX_N; i++)
while (x % i == 0)
vs.push_back(i), x /= i;
if (x > 1) { puts("-1"); return 0; }
}
ll sum = 0;
for (auto v: vs) sum += v + 1;
if (sum > MAX_N) { puts("-1"); return 0; }
int m = vs.size(), n = sum;
printf("%d\n", n);
for (int i = 0; i + 1 < m; i++) printf("%d %d\n", i + 1, i + 2);
for (int i = 0, k = m; i < m; i++)
for (int j = 0; j < vs[i]; j++)
printf("%d %d\n", i + 1, (k++) + 1);
for (int i = 0; i < n; i++)
printf("%c%c", (i < m) ? 'b' : 'g', (i + 1 < n) ? ' ' : '\n');
return 0;
}
tnakao0123