結果

問題 No.438 Cwwプログラミング入門
ユーザー uafr_csuafr_cs
提出日時 2016-10-28 22:58:04
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,575 bytes
コンパイル時間 3,621 ms
コンパイル使用メモリ 80,676 KB
実行使用メモリ 572,296 KB
最終ジャッジ日時 2024-05-03 16:11:17
合計ジャッジ時間 42,593 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,040 KB
testcase_01 WA -
testcase_02 AC 127 ms
41,352 KB
testcase_03 AC 132 ms
41,116 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 115 ms
40,080 KB
testcase_07 AC 130 ms
41,340 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 130 ms
41,084 KB
testcase_14 WA -
testcase_15 AC 118 ms
41,052 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 112 ms
40,072 KB
testcase_19 AC 131 ms
41,188 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 126 ms
41,652 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 128 ms
40,980 KB
testcase_28 AC 132 ms
40,952 KB
testcase_29 AC 127 ms
41,204 KB
testcase_30 AC 126 ms
41,096 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 113 ms
40,328 KB
testcase_39 WA -
testcase_40 AC 115 ms
40,060 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 131 ms
41,264 KB
testcase_44 WA -
testcase_45 AC 128 ms
41,616 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 RE -
testcase_49 RE -
testcase_50 AC 130 ms
41,500 KB
testcase_51 MLE -
testcase_52 WA -
testcase_53 RE -
testcase_54 AC 131 ms
41,224 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 131 ms
41,060 KB
testcase_59 WA -
testcase_60 RE -
testcase_61 WA -
testcase_62 AC 127 ms
41,524 KB
testcase_63 WA -
testcase_64 RE -
testcase_65 AC 130 ms
41,088 KB
testcase_66 WA -
testcase_67 AC 129 ms
41,104 KB
testcase_68 WA -
testcase_69 RE -
testcase_70 RE -
testcase_71 RE -
testcase_72 RE -
testcase_73 RE -
testcase_74 RE -
testcase_75 RE -
testcase_76 WA -
testcase_77 RE -
testcase_78 RE -
testcase_79 AC 131 ms
41,280 KB
testcase_80 RE -
testcase_81 AC 132 ms
41,344 KB
testcase_82 RE -
testcase_83 RE -
testcase_84 AC 135 ms
41,044 KB
testcase_85 AC 114 ms
40,112 KB
testcase_86 MLE -
testcase_87 RE -
testcase_88 AC 132 ms
41,152 KB
testcase_89 AC 135 ms
41,704 KB
testcase_90 AC 132 ms
41,320 KB
testcase_91 AC 133 ms
41,280 KB
testcase_92 AC 131 ms
41,552 KB
testcase_93 RE -
testcase_94 RE -
testcase_95 WA -
testcase_96 AC 287 ms
101,656 KB
testcase_97 WA -
testcase_98 AC 129 ms
41,084 KB
testcase_99 RE -
testcase_100 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	
	public static class Ref<T> {
		T value;
		
		public void setValue(T value){
			this.value = value;
		}
		
		public T getValue(){
			return value;
		}
	}
	
	public static long gcd(long a, long b){
		return b == 0 ? a : gcd(b, a % b);
	}
	
	public static long extcdf(long a, long b, Ref<Long> x, Ref<Long> y){
		long g = a;
		x.setValue(1l);
		y.setValue(0l);
		
		if(b != 0){
			g = extcdf(b, a % b, y, x);
			y.setValue(y.getValue() - (a / b) * x.getValue());
		}
		
		return g;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final long x = sc.nextLong();
		final long y = sc.nextLong();
		final long z = sc.nextLong();
		
		final long gcd = gcd(x, y);
		if(z % gcd != 0){
			System.out.println("mourennaihasimasenn");
		}else{
			Ref<Long> a = new Ref<Long>();
			Ref<Long> b = new Ref<Long>();
			
			extcdf(x, y, a, b);
			
			final StringBuilder oneloop = new StringBuilder();
			final boolean one_comb = Math.abs(a.getValue()) != 0 && Math.abs(b.getValue()) != 0;
			
			if(a.getValue() >= 0){
				for(int i = 0; i < Math.abs(a.getValue()); i++){
					oneloop.append('c');
				}
				for(int i = 0; i < Math.abs(a.getValue()) - 1; i++){
					oneloop.append('C');
				}
				
				for(int i = 0; i < Math.abs(b.getValue()); i++){
					oneloop.append('w');
				}
				for(int i = 0; i < Math.abs(b.getValue()) - 1; i++){
					oneloop.append('C');
				}
				
				if(one_comb){
					if(b.getValue() >= 0){
						oneloop.append('C');
					}else{
						oneloop.append('W');
					}
				}
			}else{
				for(int i = 0; i < Math.abs(b.getValue()); i++){
					oneloop.append('w');
				}
				for(int i = 0; i < Math.abs(b.getValue()) - 1; i++){
					oneloop.append('C');
				}
				
				for(int i = 0; i < Math.abs(a.getValue()); i++){
					oneloop.append('c');
				}
				for(int i = 0; i < Math.abs(a.getValue()) - 1; i++){
					oneloop.append('C');
				}
				
				if(one_comb){
					oneloop.append('W');
				}
			}
			
			//System.out.println(oneloop);
			
			final StringBuilder allloop = new StringBuilder();
			for(int i = 0; i < (z / gcd); i++){
				allloop.append(oneloop);
				if(i != 0){
					allloop.append('C');
				}
			}
			
			if(allloop.length() > 10000){
				System.out.println("mourennaihasimasenn");
			}else{
				System.out.println(allloop);
			}
			
		}
	}
}
0