結果
問題 | No.438 Cwwプログラミング入門 |
ユーザー | uafr_cs |
提出日時 | 2016-10-29 00:07:17 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,360 bytes |
コンパイル時間 | 2,386 ms |
コンパイル使用メモリ | 89,744 KB |
実行使用メモリ | 55,792 KB |
最終ジャッジ日時 | 2024-11-24 22:07:54 |
合計ジャッジ時間 | 17,957 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 118 ms
53,916 KB |
testcase_01 | AC | 121 ms
53,980 KB |
testcase_02 | AC | 110 ms
52,744 KB |
testcase_03 | AC | 105 ms
52,420 KB |
testcase_04 | AC | 114 ms
52,976 KB |
testcase_05 | AC | 103 ms
52,124 KB |
testcase_06 | AC | 108 ms
53,660 KB |
testcase_07 | AC | 123 ms
54,348 KB |
testcase_08 | AC | 109 ms
52,896 KB |
testcase_09 | AC | 104 ms
52,932 KB |
testcase_10 | AC | 116 ms
54,024 KB |
testcase_11 | AC | 117 ms
54,140 KB |
testcase_12 | AC | 104 ms
52,988 KB |
testcase_13 | AC | 108 ms
53,336 KB |
testcase_14 | AC | 104 ms
52,764 KB |
testcase_15 | AC | 110 ms
52,876 KB |
testcase_16 | AC | 106 ms
52,988 KB |
testcase_17 | AC | 118 ms
53,732 KB |
testcase_18 | AC | 117 ms
53,832 KB |
testcase_19 | AC | 101 ms
52,748 KB |
testcase_20 | AC | 115 ms
53,716 KB |
testcase_21 | AC | 121 ms
53,996 KB |
testcase_22 | AC | 124 ms
54,116 KB |
testcase_23 | AC | 131 ms
53,980 KB |
testcase_24 | AC | 123 ms
54,100 KB |
testcase_25 | AC | 108 ms
52,868 KB |
testcase_26 | AC | 104 ms
53,000 KB |
testcase_27 | AC | 106 ms
52,784 KB |
testcase_28 | AC | 106 ms
52,944 KB |
testcase_29 | AC | 116 ms
53,812 KB |
testcase_30 | AC | 110 ms
54,248 KB |
testcase_31 | AC | 115 ms
53,696 KB |
testcase_32 | AC | 102 ms
53,092 KB |
testcase_33 | AC | 104 ms
52,800 KB |
testcase_34 | WA | - |
testcase_35 | AC | 116 ms
54,120 KB |
testcase_36 | AC | 108 ms
52,876 KB |
testcase_37 | AC | 114 ms
53,856 KB |
testcase_38 | AC | 113 ms
53,632 KB |
testcase_39 | AC | 118 ms
54,108 KB |
testcase_40 | AC | 113 ms
54,044 KB |
testcase_41 | AC | 114 ms
53,992 KB |
testcase_42 | AC | 111 ms
54,016 KB |
testcase_43 | AC | 114 ms
54,156 KB |
testcase_44 | AC | 116 ms
53,944 KB |
testcase_45 | AC | 105 ms
52,888 KB |
testcase_46 | AC | 112 ms
53,740 KB |
testcase_47 | AC | 116 ms
53,984 KB |
testcase_48 | WA | - |
testcase_49 | AC | 108 ms
53,056 KB |
testcase_50 | AC | 119 ms
53,772 KB |
testcase_51 | AC | 109 ms
53,036 KB |
testcase_52 | WA | - |
testcase_53 | AC | 136 ms
54,336 KB |
testcase_54 | AC | 111 ms
52,884 KB |
testcase_55 | AC | 135 ms
54,036 KB |
testcase_56 | AC | 131 ms
54,028 KB |
testcase_57 | AC | 101 ms
52,652 KB |
testcase_58 | AC | 114 ms
53,968 KB |
testcase_59 | AC | 105 ms
53,000 KB |
testcase_60 | AC | 116 ms
54,296 KB |
testcase_61 | AC | 116 ms
53,720 KB |
testcase_62 | AC | 101 ms
52,960 KB |
testcase_63 | AC | 122 ms
53,876 KB |
testcase_64 | AC | 140 ms
53,940 KB |
testcase_65 | AC | 108 ms
52,856 KB |
testcase_66 | AC | 112 ms
53,616 KB |
testcase_67 | AC | 102 ms
52,980 KB |
testcase_68 | WA | - |
testcase_69 | AC | 117 ms
54,164 KB |
testcase_70 | AC | 128 ms
53,976 KB |
testcase_71 | AC | 103 ms
53,096 KB |
testcase_72 | AC | 101 ms
52,932 KB |
testcase_73 | AC | 112 ms
53,624 KB |
testcase_74 | AC | 118 ms
54,104 KB |
testcase_75 | AC | 113 ms
53,960 KB |
testcase_76 | WA | - |
testcase_77 | AC | 120 ms
53,948 KB |
testcase_78 | AC | 105 ms
52,788 KB |
testcase_79 | AC | 110 ms
53,500 KB |
testcase_80 | AC | 120 ms
53,876 KB |
testcase_81 | AC | 105 ms
52,912 KB |
testcase_82 | AC | 108 ms
52,852 KB |
testcase_83 | AC | 107 ms
52,884 KB |
testcase_84 | AC | 124 ms
54,252 KB |
testcase_85 | AC | 118 ms
54,172 KB |
testcase_86 | AC | 109 ms
53,004 KB |
testcase_87 | AC | 120 ms
54,516 KB |
testcase_88 | AC | 118 ms
54,012 KB |
testcase_89 | AC | 118 ms
54,624 KB |
testcase_90 | AC | 128 ms
53,968 KB |
testcase_91 | AC | 144 ms
53,976 KB |
testcase_92 | AC | 120 ms
53,888 KB |
testcase_93 | RE | - |
testcase_94 | RE | - |
testcase_95 | WA | - |
testcase_96 | AC | 126 ms
53,984 KB |
testcase_97 | AC | 126 ms
53,820 KB |
testcase_98 | AC | 115 ms
53,976 KB |
testcase_99 | AC | 118 ms
53,740 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('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{ if(diff == x){ 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{ final long diff = curr_value - z; if(x > y){ if(diff == x){ 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 == y){ 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"); } } } }