結果
問題 | No.438 Cwwプログラミング入門 |
ユーザー | uafr_cs |
提出日時 | 2016-10-28 23:20:39 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,696 bytes |
コンパイル時間 | 3,803 ms |
コンパイル使用メモリ | 87,796 KB |
実行使用メモリ | 671,736 KB |
最終ジャッジ日時 | 2024-11-24 19:53:28 |
合計ジャッジ時間 | 63,142 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 132 ms
41,256 KB |
testcase_01 | AC | 127 ms
41,356 KB |
testcase_02 | AC | 127 ms
41,504 KB |
testcase_03 | AC | 135 ms
41,432 KB |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | AC | 132 ms
41,472 KB |
testcase_07 | AC | 132 ms
39,876 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 132 ms
41,756 KB |
testcase_13 | AC | 133 ms
41,276 KB |
testcase_14 | WA | - |
testcase_15 | AC | 131 ms
41,416 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 129 ms
41,300 KB |
testcase_19 | AC | 133 ms
41,392 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 127 ms
40,916 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 127 ms
41,544 KB |
testcase_28 | AC | 127 ms
41,668 KB |
testcase_29 | AC | 133 ms
41,088 KB |
testcase_30 | AC | 131 ms
41,256 KB |
testcase_31 | AC | 133 ms
41,228 KB |
testcase_32 | AC | 134 ms
41,328 KB |
testcase_33 | AC | 132 ms
41,468 KB |
testcase_34 | WA | - |
testcase_35 | AC | 125 ms
41,356 KB |
testcase_36 | AC | 133 ms
41,528 KB |
testcase_37 | AC | 131 ms
41,476 KB |
testcase_38 | AC | 133 ms
41,272 KB |
testcase_39 | AC | 131 ms
41,004 KB |
testcase_40 | AC | 131 ms
41,404 KB |
testcase_41 | AC | 128 ms
41,296 KB |
testcase_42 | AC | 129 ms
41,344 KB |
testcase_43 | AC | 135 ms
41,264 KB |
testcase_44 | AC | 131 ms
41,132 KB |
testcase_45 | AC | 129 ms
41,436 KB |
testcase_46 | AC | 117 ms
41,544 KB |
testcase_47 | AC | 127 ms
41,544 KB |
testcase_48 | RE | - |
testcase_49 | MLE | - |
testcase_50 | AC | 138 ms
41,256 KB |
testcase_51 | MLE | - |
testcase_52 | OLE | - |
testcase_53 | MLE | - |
testcase_54 | AC | 134 ms
41,256 KB |
testcase_55 | RE | - |
testcase_56 | MLE | - |
testcase_57 | OLE | - |
testcase_58 | AC | 134 ms
41,400 KB |
testcase_59 | OLE | - |
testcase_60 | RE | - |
testcase_61 | WA | - |
testcase_62 | AC | 135 ms
41,168 KB |
testcase_63 | OLE | - |
testcase_64 | MLE | - |
testcase_65 | AC | 135 ms
41,356 KB |
testcase_66 | OLE | - |
testcase_67 | AC | 131 ms
41,356 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 | 127 ms
41,580 KB |
testcase_80 | RE | - |
testcase_81 | AC | 129 ms
41,124 KB |
testcase_82 | RE | - |
testcase_83 | RE | - |
testcase_84 | AC | 134 ms
41,088 KB |
testcase_85 | AC | 135 ms
41,388 KB |
testcase_86 | RE | - |
testcase_87 | RE | - |
testcase_88 | AC | 129 ms
41,208 KB |
testcase_89 | AC | 133 ms
41,352 KB |
testcase_90 | WA | - |
testcase_91 | AC | 139 ms
41,344 KB |
testcase_92 | WA | - |
testcase_93 | RE | - |
testcase_94 | RE | - |
testcase_95 | OLE | - |
testcase_96 | OLE | - |
testcase_97 | OLE | - |
testcase_98 | AC | 119 ms
39,944 KB |
testcase_99 | RE | - |
testcase_100 | RE | - |
ソースコード
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{ Ref<Long> a = new Ref<Long>(); Ref<Long> b = new Ref<Long>(); a.setValue(0l); b.setValue(0l); extcdf(x, y, a, b); final long x_size = Math.abs(a.getValue()) * (z / gcd); final long y_size = Math.abs(b.getValue()) * (z / gcd); final StringBuilder x_sum = new StringBuilder(); final StringBuilder y_sum = new StringBuilder(); for(long i = 0; i < x_size; i++){ x_sum.append('c'); if(i != 0){ x_sum.append('C'); } } for(long i = 0; i < y_size; i++){ y_sum.append('w'); if(i != 0){ y_sum.append('C'); } } final StringBuilder answer = new StringBuilder(); if(a.getValue() >= 0){ answer.append(y_sum); answer.append(x_sum); if(x_size != 0 && y_size != 0){ if(b.getValue() >= 0){ answer.append('C'); }else{ answer.append('W'); } } }else{ answer.append(x_sum); answer.append(y_sum); if(x_size != 0 && y_size != 0){ answer.append('W'); } } //System.out.println(exec(x, y, answer.toString().toCharArray())); System.out.println(answer); } } }