結果
| 問題 | No.438 Cwwプログラミング入門 |
| コンテスト | |
| ユーザー |
ldsyb
|
| 提出日時 | 2026-09-11 23:09:48 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,799 bytes |
| 記録 | |
| コンパイル時間 | 4,044 ms |
| コンパイル使用メモリ | 376,812 KB |
| 実行使用メモリ | 249,404 KB |
| 最終ジャッジ日時 | 2026-09-11 23:10:06 |
| 合計ジャッジ時間 | 14,549 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 34 WA * 64 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
pair<int64_t, pair<int64_t, int64_t>> ext_gcd(int64_t x, int64_t y) {
if (y == 0) {
return {x, {1, 0}};
}
auto [g, p] = ext_gcd(y, x % y);
auto [u, v] = p;
// g == u * y + v * (x % y)
// == u * y + v * (x - x / y * y)
// == u * y + v * x - x / y * y * v
// == v * x + (u - x / y * v) * y
int64_t nu = v, nv = u - x / y * v;
return {g, {nu, nv}};
}
int main() {
int64_t x, y, z;
cin >> x >> y >> z;
auto [g, p] = ext_gcd(x, y);
auto [u, v] = p;
if (g == 0) {
if (z == 0) {
cout << "ccW" << endl;
return 0;
}
cout << "NO" << endl;
return 0;
}
if (z % g != 0) {
cout << "NO" << endl;
return 0;
}
string ans = "";
if (0 <= u) {
for (int64_t i = 0; i < u; i++) {
ans += 'c';
}
for (int64_t i = 0; i < u - 1; i++) {
ans += 'C';
}
} else {
for (int64_t i = 0; i < -u + 2; i++) {
ans += 'c';
}
for (int64_t i = 0; i < -u + 1; i++) {
ans += 'W';
}
}
if (0 <= v) {
for (int64_t i = 0; i < v; i++) {
ans += 'w';
}
for (int64_t i = 0; i < v - 1; i++) {
ans += 'C';
}
} else {
for (int64_t i = 0; i < -v + 2; i++) {
ans += 'w';
}
for (int64_t i = 0; i < -v + 1; i++) {
ans += 'W';
}
}
ans += 'C';
if (100000 < ans.size()) {
cout << "NO" << endl;
return 0;
}
cout << ans << endl;
return 0;
}
ldsyb