結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
![]() |
提出日時 | 2016-10-29 13:28:08 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,505 bytes |
コンパイル時間 | 2,477 ms |
コンパイル使用メモリ | 80,092 KB |
実行使用メモリ | 54,272 KB |
最終ジャッジ日時 | 2024-11-24 23:08:37 |
合計ジャッジ時間 | 18,360 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 34 WA * 59 RE * 5 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; void solve() throws IOException { int x = ni(); int y = ni(); int z = ni(); for (int i = 0; i <= 4999; i++) { if ((z - x * i) % y == 0) { int t = (z - x * i) / y; if (t >= -4998 && t <= 4999) { output(i, t); return; } } if ((z - x * (-i)) % y == 0) { int t = (z - x * (-i)) / y; if (t >= -4998 && t <= 4999) { output(-i, t); return; } } } out.println("mourennaihasimasenn"); } void output(int x, int y) { String ans = ""; if (x < 0) { for (int i = 0; i < y; i++) { if (i == 0) ans += "w"; else ans += "wC"; } for (int i = 0; i < x; i++) { ans += "cW"; } } else if (y < 0) { for (int i = 0; i < x; i++) { if (i == 0) ans += "c"; else ans += "cC"; } for (int i = 0; i < x; i++) { ans += "wW"; } } else { for (int i = 0; i < y; i++) { if (i == 0) ans+="c"; else ans+="cC"; } for (int i = 0; i < x; i++) { if ("".equals(ans)) ans += "w"; ans+="wC"; } } out.println(ans); } int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); } int lcm(int a, int b) { return a / gcd(a, b) * b; } int[] extgcd(int a, int b, int[] is) { if (a == 0) { is[0] = 0; is[1] = 1; is[2] = b; } else { extgcd(b % a, a, is); int x = is[1] - b / a * is[0]; is[1] = is[0]; is[0] = x; } return is; } String ns() throws IOException { while (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine(), " "); } return tok.nextToken(); } int ni() throws IOException { return Integer.parseInt(ns()); } long nl() throws IOException { return Long.parseLong(ns()); } double nd() throws IOException { return Double.parseDouble(ns()); } String[] nsa(int n) throws IOException { String[] res = new String[n]; for (int i = 0; i < n; i++) { res[i] = ns(); } return res; } int[] nia(int n) throws IOException { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = ni(); } return res; } long[] nla(int n) throws IOException { long[] res = new long[n]; for (int i = 0; i < n; i++) { res[i] = nl(); } return res; } public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); tok = new StringTokenizer(""); Main main = new Main(); main.solve(); out.close(); } }