結果

問題 No.438 Cwwプログラミング入門
ユーザー uzumakiyorumunnuzumakiyorumunn
提出日時 2017-06-10 04:28:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,844 bytes
コンパイル時間 1,889 ms
コンパイル使用メモリ 62,376 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 06:17:37
合計ジャッジ時間 97,580 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
4,372 KB
testcase_01 AC 96 ms
4,372 KB
testcase_02 AC 1,881 ms
4,372 KB
testcase_03 AC 1,881 ms
4,372 KB
testcase_04 AC 1,884 ms
4,372 KB
testcase_05 AC 1,880 ms
4,372 KB
testcase_06 AC 1,884 ms
4,372 KB
testcase_07 AC 1,882 ms
4,372 KB
testcase_08 AC 96 ms
4,372 KB
testcase_09 AC 66 ms
4,372 KB
testcase_10 AC 86 ms
4,372 KB
testcase_11 AC 84 ms
4,372 KB
testcase_12 AC 96 ms
4,372 KB
testcase_13 AC 1,831 ms
4,372 KB
testcase_14 AC 95 ms
4,372 KB
testcase_15 AC 1,983 ms
4,372 KB
testcase_16 AC 97 ms
4,372 KB
testcase_17 AC 93 ms
4,372 KB
testcase_18 AC 1,855 ms
4,372 KB
testcase_19 AC 1,891 ms
4,372 KB
testcase_20 AC 95 ms
4,372 KB
testcase_21 WA -
testcase_22 AC 88 ms
4,372 KB
testcase_23 AC 95 ms
4,372 KB
testcase_24 AC 1,869 ms
4,372 KB
testcase_25 AC 95 ms
4,372 KB
testcase_26 WA -
testcase_27 AC 1,861 ms
4,372 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1,843 ms
4,372 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1,868 ms
4,372 KB
testcase_39 WA -
testcase_40 AC 1,861 ms
4,372 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 1,885 ms
4,372 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 TLE -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 1,970 ms
4,372 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 TLE -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 1,937 ms
4,372 KB
testcase_63 WA -
testcase_64 WA -
testcase_65 TLE -
testcase_66 WA -
testcase_67 AC 1,887 ms
4,372 KB
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 AC 1,987 ms
4,372 KB
testcase_79 TLE -
testcase_80 AC 1,429 ms
4,372 KB
testcase_81 AC 1,936 ms
4,372 KB
testcase_82 TLE -
testcase_83 AC 1,928 ms
4,372 KB
testcase_84 AC 1,904 ms
4,372 KB
testcase_85 TLE -
testcase_86 TLE -
testcase_87 AC 1,875 ms
4,372 KB
testcase_88 WA -
testcase_89 WA -
testcase_90 AC 621 ms
4,372 KB
testcase_91 WA -
testcase_92 AC 446 ms
4,372 KB
testcase_93 WA -
testcase_94 AC 1,885 ms
4,372 KB
testcase_95 AC 112 ms
4,372 KB
testcase_96 AC 110 ms
4,372 KB
testcase_97 WA -
testcase_98 AC 1,892 ms
4,372 KB
testcase_99 AC 1,850 ms
4,372 KB
testcase_100 WA -
権限があれば一括ダウンロードができます

ソースコード

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;

	while(ccc<10000){
		zz1=ccc*y;
		xc1=0,yc1=ccc;
		for(int i=0;i<100000;i++){
			if(zz1==z) break;
			else if(zz1>z){
				zz1-=y;
				yc1--;
			}
			else{
				zz1+=x;
				xc1++;
			}
		}
		zz2=ccc*x;
		xc2=ccc,yc2=0;
		for(int i=0;i<100000;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) ans+="W";
		else ans+="C";

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