結果

問題 No.438 Cwwプログラミング入門
ユーザー uzumakiyorumunnuzumakiyorumunn
提出日時 2017-06-10 04:47:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,451 ms / 2,000 ms
コード長 2,073 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 62,704 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 09:34:22
合計ジャッジ時間 75,977 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 229 ms
4,348 KB
testcase_01 AC 207 ms
4,348 KB
testcase_02 AC 1,218 ms
4,348 KB
testcase_03 AC 1,129 ms
4,348 KB
testcase_04 AC 1,127 ms
4,348 KB
testcase_05 AC 1,131 ms
4,348 KB
testcase_06 AC 1,130 ms
4,348 KB
testcase_07 AC 1,131 ms
4,348 KB
testcase_08 AC 228 ms
4,348 KB
testcase_09 AC 400 ms
4,348 KB
testcase_10 AC 270 ms
4,348 KB
testcase_11 AC 253 ms
4,348 KB
testcase_12 AC 190 ms
4,348 KB
testcase_13 AC 1,281 ms
4,348 KB
testcase_14 AC 215 ms
4,348 KB
testcase_15 AC 1,194 ms
4,348 KB
testcase_16 AC 299 ms
4,348 KB
testcase_17 AC 191 ms
4,348 KB
testcase_18 AC 1,270 ms
4,348 KB
testcase_19 AC 1,139 ms
4,348 KB
testcase_20 AC 276 ms
4,348 KB
testcase_21 AC 228 ms
4,348 KB
testcase_22 AC 276 ms
4,348 KB
testcase_23 AC 256 ms
4,348 KB
testcase_24 AC 1,115 ms
4,348 KB
testcase_25 AC 273 ms
4,348 KB
testcase_26 AC 193 ms
4,348 KB
testcase_27 AC 1,269 ms
4,348 KB
testcase_28 AC 397 ms
4,348 KB
testcase_29 AC 229 ms
4,348 KB
testcase_30 AC 1,261 ms
4,348 KB
testcase_31 AC 193 ms
4,348 KB
testcase_32 AC 221 ms
4,348 KB
testcase_33 AC 189 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 213 ms
4,348 KB
testcase_36 AC 214 ms
4,348 KB
testcase_37 AC 197 ms
4,348 KB
testcase_38 AC 1,275 ms
4,348 KB
testcase_39 AC 213 ms
4,348 KB
testcase_40 AC 1,109 ms
4,348 KB
testcase_41 AC 246 ms
4,348 KB
testcase_42 AC 190 ms
4,348 KB
testcase_43 AC 1,132 ms
4,348 KB
testcase_44 AC 257 ms
4,348 KB
testcase_45 AC 228 ms
4,348 KB
testcase_46 AC 206 ms
4,348 KB
testcase_47 AC 194 ms
4,348 KB
testcase_48 AC 479 ms
4,348 KB
testcase_49 AC 520 ms
4,348 KB
testcase_50 AC 1,325 ms
4,348 KB
testcase_51 AC 520 ms
4,348 KB
testcase_52 AC 474 ms
4,348 KB
testcase_53 AC 408 ms
4,348 KB
testcase_54 AC 1,307 ms
4,348 KB
testcase_55 AC 553 ms
4,348 KB
testcase_56 AC 437 ms
4,348 KB
testcase_57 AC 412 ms
4,348 KB
testcase_58 AC 1,451 ms
4,348 KB
testcase_59 AC 452 ms
4,348 KB
testcase_60 AC 416 ms
4,348 KB
testcase_61 AC 438 ms
4,348 KB
testcase_62 AC 1,309 ms
4,348 KB
testcase_63 AC 486 ms
4,348 KB
testcase_64 AC 354 ms
4,348 KB
testcase_65 AC 1,438 ms
4,348 KB
testcase_66 AC 224 ms
4,348 KB
testcase_67 AC 1,120 ms
4,348 KB
testcase_68 AC 1 ms
4,348 KB
testcase_69 AC 889 ms
4,348 KB
testcase_70 AC 926 ms
4,348 KB
testcase_71 AC 1,154 ms
4,348 KB
testcase_72 AC 853 ms
4,348 KB
testcase_73 AC 1,153 ms
4,348 KB
testcase_74 AC 1,000 ms
4,348 KB
testcase_75 AC 880 ms
4,348 KB
testcase_76 AC 2 ms
4,348 KB
testcase_77 AC 1,014 ms
4,348 KB
testcase_78 AC 1,302 ms
4,348 KB
testcase_79 AC 1,375 ms
4,348 KB
testcase_80 AC 1,145 ms
4,348 KB
testcase_81 AC 1,160 ms
4,348 KB
testcase_82 AC 1,311 ms
4,348 KB
testcase_83 AC 1,309 ms
4,348 KB
testcase_84 AC 1,139 ms
4,348 KB
testcase_85 AC 1,206 ms
4,348 KB
testcase_86 AC 1,380 ms
4,348 KB
testcase_87 AC 1,123 ms
4,348 KB
testcase_88 AC 266 ms
4,348 KB
testcase_89 AC 599 ms
4,348 KB
testcase_90 AC 598 ms
4,348 KB
testcase_91 AC 462 ms
4,348 KB
testcase_92 AC 462 ms
4,348 KB
testcase_93 AC 2 ms
4,348 KB
testcase_94 AC 1,130 ms
4,348 KB
testcase_95 AC 492 ms
4,348 KB
testcase_96 AC 489 ms
4,348 KB
testcase_97 AC 876 ms
4,348 KB
testcase_98 AC 1,266 ms
4,348 KB
testcase_99 AC 1,260 ms
4,348 KB
testcase_100 AC 1,035 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main(){

	long long x,y,z;
	long long xc,yc,xc1,xc2,yc1,yc2;
	long long zz,zz1,zz2;
	long long tzz,txc,tyc;
	long long ccc=0;
	string ans;

	cin>>x>>y>>z;
	if(z==0){
		cout<<"ccWcCcW"<<endl;
	}
	else{
		while(ccc<=20000){
			zz1=(ccc-10000)*y;
			xc1=0,yc1=ccc-10000;
			for(int i=0;i<30000;i++){
				if(zz1==z) break;
				else if(zz1>z){
					zz1-=y;
					yc1--;
				}
				else{
					zz1+=x;
					xc1++;
				}
			}
			zz2=(ccc-10000)*x;
			xc2=ccc-10000,yc2=0;
			for(int i=0;i<30000;i++){
				if(zz2==z) break;
				else if(zz2>z){
					zz2-=x;
					xc2--;
				}
				else{
					zz2+=y;
					yc2++;
				}
			}
			if(zz1!=z){
				zz=zz2;
				yc=yc2;
				xc=xc2;
			}
			else if(zz2!=z){
				zz=zz1;
				yc=yc1;
				xc=xc1;
			}
			else if(abs(xc1)+abs(yc1)<abs(xc2)+abs(yc2)){
				zz=zz1;
				yc=yc1;
				xc=xc1;
			}
			else{
				zz=zz2;
				yc=yc2;
				xc=xc2;
			}
			if(ccc==0){
				tzz=zz;
				tyc=yc;
				txc=xc;
			}else{
				long long azz,ayc,axc;
				if(zz!=z){
					azz=tzz;
					ayc=tyc;
					axc=txc;
				}
				else if(tzz!=z){
					azz=zz;
					ayc=yc;
					axc=xc;
				}
				else if(abs(txc)+abs(tyc)<abs(xc)+abs(yc)){
					azz=tzz;
					ayc=tyc;
					axc=txc;
				}
				else{
					azz=zz;
					ayc=yc;
					axc=xc;
				}
			
				tzz=azz;
				tyc=ayc;
				txc=axc;
			}
			ccc++;
		}
		tzz=zz;
		tyc=yc;
		txc=xc;
		if(zz!=z) printf("NO\n");
		else{
			ans="";
			if(xc<0){
				for(int i=0;i<-xc;i++){
					ans+="c";
				}
				for(int i=0;i<-xc-1;i++){
					ans+="C";
				}
			}
			if(yc<0){
				for(int i=0;i<-yc;i++){
					ans+="w";
				}
				for(int i=0;i<-yc-1;i++){
					ans+="C";
				}
			}
			if(xc>0){
				for(int i=0;i<xc;i++){
					ans+="c";
				}
				for(int i=0;i<xc-1;i++){
					ans+="C";
				}
			}
			if(yc>0){
				for(int i=0;i<yc;i++){
					ans+="w";
				}
				for(int i=0;i<yc-1;i++){
					ans+="C";
				}
			}
			if(xc!=0&&yc!=0){
				if(xc<0||yc<0) ans+="W";
				else ans+="C";
			}

			if(ans.size()<=10000) cout<<ans<<endl;
			else cout<<"NO"<<endl;
		}
	}
}
0