結果
問題 | No.438 Cwwプログラミング入門 |
ユーザー | uafr_cs |
提出日時 | 2016-10-28 23:56:05 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,380 bytes |
コンパイル時間 | 3,449 ms |
コンパイル使用メモリ | 81,004 KB |
実行使用メモリ | 54,652 KB |
最終ジャッジ日時 | 2024-11-24 21:20:16 |
合計ジャッジ時間 | 21,874 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 135 ms
41,060 KB |
testcase_01 | AC | 135 ms
40,940 KB |
testcase_02 | AC | 135 ms
41,048 KB |
testcase_03 | AC | 132 ms
41,432 KB |
testcase_04 | AC | 139 ms
41,376 KB |
testcase_05 | AC | 128 ms
40,268 KB |
testcase_06 | AC | 120 ms
39,820 KB |
testcase_07 | AC | 133 ms
41,100 KB |
testcase_08 | AC | 138 ms
41,208 KB |
testcase_09 | AC | 136 ms
41,132 KB |
testcase_10 | AC | 137 ms
41,220 KB |
testcase_11 | AC | 137 ms
41,364 KB |
testcase_12 | AC | 136 ms
41,036 KB |
testcase_13 | AC | 134 ms
41,332 KB |
testcase_14 | AC | 124 ms
40,044 KB |
testcase_15 | AC | 134 ms
41,340 KB |
testcase_16 | AC | 132 ms
41,000 KB |
testcase_17 | AC | 138 ms
41,048 KB |
testcase_18 | AC | 132 ms
41,052 KB |
testcase_19 | AC | 120 ms
39,884 KB |
testcase_20 | AC | 136 ms
41,376 KB |
testcase_21 | AC | 136 ms
41,580 KB |
testcase_22 | AC | 136 ms
41,488 KB |
testcase_23 | AC | 136 ms
41,136 KB |
testcase_24 | AC | 134 ms
41,460 KB |
testcase_25 | AC | 136 ms
41,264 KB |
testcase_26 | AC | 122 ms
39,852 KB |
testcase_27 | AC | 135 ms
41,336 KB |
testcase_28 | AC | 136 ms
41,448 KB |
testcase_29 | AC | 139 ms
41,596 KB |
testcase_30 | AC | 135 ms
41,500 KB |
testcase_31 | AC | 134 ms
41,076 KB |
testcase_32 | AC | 133 ms
41,144 KB |
testcase_33 | AC | 136 ms
41,224 KB |
testcase_34 | WA | - |
testcase_35 | AC | 136 ms
41,168 KB |
testcase_36 | AC | 138 ms
41,336 KB |
testcase_37 | AC | 135 ms
41,180 KB |
testcase_38 | AC | 134 ms
41,340 KB |
testcase_39 | AC | 133 ms
41,216 KB |
testcase_40 | AC | 134 ms
41,316 KB |
testcase_41 | AC | 135 ms
41,372 KB |
testcase_42 | AC | 134 ms
41,364 KB |
testcase_43 | AC | 132 ms
41,080 KB |
testcase_44 | AC | 136 ms
41,484 KB |
testcase_45 | AC | 135 ms
41,144 KB |
testcase_46 | AC | 134 ms
40,960 KB |
testcase_47 | AC | 133 ms
41,216 KB |
testcase_48 | WA | - |
testcase_49 | AC | 138 ms
41,112 KB |
testcase_50 | AC | 136 ms
41,052 KB |
testcase_51 | AC | 140 ms
41,648 KB |
testcase_52 | WA | - |
testcase_53 | AC | 148 ms
41,436 KB |
testcase_54 | AC | 137 ms
41,352 KB |
testcase_55 | AC | 146 ms
41,300 KB |
testcase_56 | AC | 148 ms
41,472 KB |
testcase_57 | AC | 136 ms
41,320 KB |
testcase_58 | AC | 132 ms
41,560 KB |
testcase_59 | AC | 135 ms
41,164 KB |
testcase_60 | AC | 134 ms
41,124 KB |
testcase_61 | AC | 123 ms
39,892 KB |
testcase_62 | AC | 133 ms
41,164 KB |
testcase_63 | AC | 147 ms
41,300 KB |
testcase_64 | AC | 150 ms
41,712 KB |
testcase_65 | AC | 136 ms
41,360 KB |
testcase_66 | AC | 138 ms
41,216 KB |
testcase_67 | AC | 120 ms
40,188 KB |
testcase_68 | WA | - |
testcase_69 | AC | 122 ms
40,168 KB |
testcase_70 | AC | 136 ms
41,340 KB |
testcase_71 | AC | 135 ms
41,240 KB |
testcase_72 | AC | 137 ms
41,252 KB |
testcase_73 | AC | 120 ms
40,160 KB |
testcase_74 | AC | 137 ms
41,232 KB |
testcase_75 | AC | 134 ms
41,224 KB |
testcase_76 | WA | - |
testcase_77 | AC | 136 ms
41,400 KB |
testcase_78 | AC | 129 ms
40,144 KB |
testcase_79 | AC | 134 ms
41,464 KB |
testcase_80 | AC | 138 ms
41,396 KB |
testcase_81 | AC | 135 ms
40,920 KB |
testcase_82 | AC | 140 ms
41,388 KB |
testcase_83 | AC | 141 ms
41,348 KB |
testcase_84 | AC | 133 ms
40,976 KB |
testcase_85 | AC | 120 ms
39,820 KB |
testcase_86 | AC | 142 ms
41,352 KB |
testcase_87 | AC | 140 ms
41,596 KB |
testcase_88 | AC | 136 ms
41,116 KB |
testcase_89 | AC | 147 ms
41,560 KB |
testcase_90 | AC | 139 ms
41,704 KB |
testcase_91 | AC | 148 ms
41,456 KB |
testcase_92 | AC | 127 ms
40,156 KB |
testcase_93 | RE | - |
testcase_94 | RE | - |
testcase_95 | WA | - |
testcase_96 | AC | 140 ms
41,640 KB |
testcase_97 | AC | 150 ms
41,804 KB |
testcase_98 | AC | 134 ms
41,032 KB |
testcase_99 | AC | 141 ms
41,608 KB |
testcase_100 | WA | - |
ソースコード
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 long exec(long x, long y, char[] program){ LinkedList<Long> stack = new LinkedList<Long>(); for(final char ch : program){ switch(ch){ case 'c': stack.addFirst(x); break; case 'w': stack.addFirst(y); break; case 'C': final long a_c = stack.poll(); final long b_c = stack.poll(); stack.addFirst(a_c + b_c); break; case 'W': final long a_w = stack.poll(); final long b_w = stack.poll(); stack.addFirst(a_w - b_w); break; } } return stack.poll(); } 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{ LinkedList<Character> answer_list = new LinkedList<>(); long curr_value = 0; while(curr_value != z && answer_list.size() <= 10000){ if(curr_value < z){ final long diff = z - curr_value; if(x > y){ //if(diff > y){ answer_list.addLast('c'); if(answer_list.size() != 1){ answer_list.addLast('C'); } curr_value += x; /*}else{ answer_list.addLast('w'); if(answer_list.size() != 1){ answer_list.addLast('C'); } curr_value += y; }*/ }else{ //if(diff > x){ answer_list.addLast('w'); if(answer_list.size() != 1){ answer_list.addLast('C'); } curr_value += y; /*}else{ answer_list.addLast('c'); if(answer_list.size() != 1){ answer_list.addLast('C'); } curr_value += x; }*/ } }else{ final long diff = curr_value - z; if(x > y){ /*if(diff > y){ answer_list.addFirst('c'); if(answer_list.size() != 1){ answer_list.addLast('W'); } curr_value -= x; }else{*/ answer_list.addFirst('w'); if(answer_list.size() != 1){ answer_list.addLast('W'); } curr_value -= y; //} }else{ /*if(diff > x){ answer_list.addFirst('w'); if(answer_list.size() != 1){ answer_list.addLast('W'); } curr_value -= y; }else{*/ answer_list.addFirst('c'); if(answer_list.size() != 1){ answer_list.addLast('W'); } curr_value -= x; //} } } } //System.out.println(answer_list); if(curr_value == z && answer_list.size() <= 10000){ StringBuilder sb = new StringBuilder(); for(final char ch : answer_list){ sb.append(ch); } System.out.println(sb); }else{ System.out.println("mourennaihasimasenn"); } } } }