結果

問題 No.438 Cwwプログラミング入門
ユーザー mamekin
提出日時 2016-10-28 23:16:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,972 bytes
コンパイル時間 1,199 ms
コンパイル使用メモリ 109,704 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 21:45:33
合計ジャッジ時間 4,844 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 98
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#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 solve(int x, int y)
{
if(x < 0){
string s = solve(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;
}
string ans;
if(x == 0 && y == 0){
ans = "ccW";
}
else if(y < 0){
if(x == 0){
ans = string(-y, 'w') + "ccW" + string(-y, 'W');
}
else{
ans = string(-y, 'w') + string(x, 'c') +
string(x - 1, 'C') + string(-y, 'W');
}
}
else{
ans = string(x, 'c') + string(y, 'w') +
string(x + y - 1, 'C');
}
return ans;
}
int main()
{
long long x, y, z;
cin >> x >> y >> z;
if(x == 0 && y == 0){
if(z == 0)
cout << "c" << endl;
else
cout << "mourennaihasimasenn" << endl;
return 0;
}
for(int i=-MAX; i<=MAX; ++i){
long long a = z - x * i;
long long j;
if(y == 0){
if(a != 0)
continue;
j = 0;
}
else{
if(a % y != 0)
continue;
j = a / y;
if((abs(i) + abs(j)) * 2 - 1 > MAX)
continue;
}
string ans = solve(i, j);
if(ans.size() > MAX)
continue;
cout << ans << endl;
return 0;
}
cout << "mourennaihasimasenn" << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0