結果

問題 No.438 Cwwプログラミング入門
ユーザー fura
提出日時 2020-10-13 01:11:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 828 bytes
コンパイル時間 2,032 ms
コンパイル使用メモリ 195,004 KB
最終ジャッジ日時 2025-01-15 06:58:23
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 98
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	lint a,b,c; cin>>a>>b>>c;

	if(c==0){
		cout<<"ccW\n";
		return 0;
	}

	for(int x=1;x<=5000;x++) if(a*x==c) {
		cout<<string(x,'c')<<string(x-1,'C')<<"\n";
		return 0;
	}
	for(int y=1;y<=5000;y++) if(b*y==c) {
		cout<<string(y,'w')<<string(y-1,'C')<<"\n";
		return 0;
	}
	for(int x=1;x<=5000;x++) for(int y=1;y<=5000-x;y++) {
		if(a*x+b*y==c){
			cout<<string(y,'w')<<string(y-1,'C')<<string(x,'c')<<string(x-1,'C')<<"C\n";
			return 0;
		}
		if(a*x-b*y==c){
			cout<<string(y,'w')<<string(y-1,'C')<<string(x,'c')<<string(x-1,'C')<<"W\n";
			return 0;
		}
		if(-a*x+b*y==c){
			cout<<string(x,'c')<<string(x-1,'C')<<string(y,'w')<<string(y-1,'C')<<"W\n";
			return 0;
		}
	}
	cout<<"NO\n";

	return 0;
}
0