結果

問題 No.438 Cwwプログラミング入門
ユーザー Lepton_s
提出日時 2016-10-28 23:03:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,383 bytes
コンパイル時間 1,380 ms
コンパイル使用メモリ 86,508 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 21:45:24
合計ジャッジ時間 4,550 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 98
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<25;
typedef pair<int,int> P;
typedef long long ll;
typedef unsigned long long ull;

#define N 10000
string ng = "mourennaihasimasenn";

int main(){
	ll x, y, z;
	cin>>x>>y>>z;
	if(z==0){
		cout<<"wwW"<<endl;
		return 0;
	}
	ll g = __gcd(x, y);
	if((x==0&&y==0) || z%g){
		cout<<ng<<endl;
		return 0;
	}
	x /= g; y /= g; z /= g;
	if(x*y==0){
		ll m = max(x, y);
		ll c = z/m;
		if(c*2-1>N){
			cout<<ng<<endl;
			return 0;
		}
		cout<<string(c, x>y?'c':'w')+string(c-1, 'C')<<endl;
		return 0;
	}
	for(int i = -N/2; i <= N/2; i++){
		ll z2 = z-i*x;
		ll c = z2/y;
		ll d = abs(i)+abs(c);
		if(z2%y || d*2-1>N) continue;
		if(i<0){
			cout<<string(-i, 'c')+string(c, 'w')+string(c-1, 'C')+string(-i, 'W')<<endl;
		} else if(c>0){
			cout<<string(i, 'c')+string(c, 'w')+string(d-1, 'C')<<endl;
		} else {
			cout<<string(-c, 'w')+string(i, 'c')+string(i-1, 'C')+string(-c, 'W')<<endl;
		}
		return 0;
	}

	cout<<ng<<endl;
	return 0;
}
0