結果
| 問題 |
No.438 Cwwプログラミング入門
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-29 01:34:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,983 bytes |
| コンパイル時間 | 1,368 ms |
| コンパイル使用メモリ | 106,492 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-27 22:11:10 |
| 合計ジャッジ時間 | 5,000 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 98 |
ソースコード
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
const int MAX = 10000;
string makeCommand(int x, int y)
{
if(x < 0){
string s = makeCommand(y, x);
for(unsigned i=0; i<s.size(); ++i){
if(s[i] == 'c')
s[i] = 'w';
else if(s[i] == 'w')
s[i] = 'c';
}
return s;
}
if(y < 0){
return string(-y, 'w') + string(x, 'c') +
string(x - 1, 'C') + string(-y, 'W');
}
else{
return string(x, 'c') + string(y, 'w') +
string(x + y - 1, 'C');
}
}
string solve(int x, int y, int z)
{
if(z == 0){
return "ccW";
}
else if(x == 0 && y == 0){
return "mourennaihasimasenn";
}
else if(x == 0){
if(z % y == 0 && z / y * 2 - 1 <= MAX)
return string(z / y, 'w') + string(z / y - 1, 'C');
else
return "mourennaihasimasenn";
}
else if(y == 0){
if(z % x == 0 && z / x * 2 - 1 <= MAX)
return string(z / x, 'c') + string(z / x - 1, 'C');
else
return "mourennaihasimasenn";
}
for(long long i=-MAX; i<=MAX; ++i){
long long a = z - x * i;
if(a % y != 0)
continue;
long long j = a / y;
long long len = abs(i) + abs(j);
len = len * 2 - 1;
if(len > MAX)
continue;
return makeCommand(i, j);
}
return "mourennaihasimasenn";
}
int main()
{
long long x, y, z;
cin >> x >> y >> z;
cout << solve(x, y, z) << endl;
return 0;
}