結果
| 問題 |
No.438 Cwwプログラミング入門
|
| コンテスト | |
| ユーザー |
mayoko_
|
| 提出日時 | 2016-10-28 23:13:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,203 bytes |
| コンパイル時間 | 644 ms |
| コンパイル使用メモリ | 80,016 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-24 18:46:55 |
| 合計ジャッジ時間 | 4,799 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 85 WA * 13 |
ソースコード
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
bool solve(ll x, ll y, ll z, char c1, char c2, char C1, char C2) {
for (int i = 0; i < 6000; ++i) {
ll tmp = i*x;
if (tmp > z) {
ll rest = tmp-z;
if (rest%y == 0) {
ll j = rest/y;
if (2*i+2*j-1 <= 10000) {
string ans;
for (int k = 0; k < j; ++k)
ans += c2;
for (int k = 0; k < i; ++k)
ans += c1;
for (int k = 0; k < i-1; ++k)
ans += C1;
for (int k = 0; k < j; ++k)
ans += C2;
cout << ans << endl;
return true;
}
}
} else if (tmp == z) {
string ans;
if (2*i-1 <= 10000) {
for (int k = 0; k < i; ++k)
ans += c1;
for (int k = 0; k < i-1; ++k)
ans += C1;
cout << ans << endl;
return true;
}
} else {
ll rest = z-tmp;
if (rest%y == 0) {
ll j = rest/y;
if (2*i+2*j-1 <= 10000) {
string ans;
for (int k = 0; k < j; ++k)
ans += c2;
for (int k = 0; k < i; ++k)
ans += c1;
for (int k = 0; k < i+j-1; ++k)
ans += C1;
cout << ans << endl;
return true;
}
}
}
}
return false;
}
int main() {
const string no = "mourennaihasimasenn";
ll x, y, z;
cin >> x >> y >> z;
if (x*y == 0) {
if (x == 0) {
if (y == 0) {
if (z == 0) cout << "w" << endl;
else cout << no << endl;
} else {
if (z%y == 0) {
ll num = z/y;
if (2*num-1 <= 10000) {
string ans;
for (int i = 0; i < num; ++i)
ans += 'w';
for (int i = 0; i < num-1; ++i)
ans += 'C';
cout << ans << endl;
} else cout << no << endl;
} else {
cout << no << endl;
}
}
} else {
if (z%x == 0) {
ll num = z/x;
if (2*num-1 <= 10000) {
string ans;
for (int i = 0; i < num; ++i)
ans += 'c';
for (int i = 0; i < num-1; ++i)
ans += 'C';
cout << ans << endl;
} else cout << no << endl;
} else {
cout << no << endl;
}
}
return 0;
}
if (solve(x, y, z, 'c', 'w', 'C', 'W')) return 0;
if (solve(y, x, z, 'w', 'c', 'W', 'C')) return 0;
cout << no << endl;
return 0;
}
mayoko_