結果
問題 | No.321 (P,Q)-サンタと街の子供たち |
ユーザー | Grenache |
提出日時 | 2015-12-14 00:26:35 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,541 bytes |
コンパイル時間 | 3,886 ms |
コンパイル使用メモリ | 75,292 KB |
実行使用メモリ | 59,536 KB |
最終ジャッジ日時 | 2023-10-13 15:07:47 |
合計ジャッジ時間 | 12,424 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
49,888 KB |
testcase_01 | AC | 40 ms
49,416 KB |
testcase_02 | AC | 40 ms
49,364 KB |
testcase_03 | AC | 40 ms
49,896 KB |
testcase_04 | AC | 38 ms
47,456 KB |
testcase_05 | AC | 40 ms
49,360 KB |
testcase_06 | AC | 40 ms
49,512 KB |
testcase_07 | AC | 40 ms
49,560 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 40 ms
49,640 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 305 ms
58,088 KB |
testcase_16 | AC | 181 ms
55,964 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 142 ms
55,788 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Iterator; public class Main_yukicoder321 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int p = sc.nextInt(); int q = sc.nextInt(); int n = sc.nextInt(); int ret = 0; for (int i = 0; i < n; i++) { int x = sc.nextInt(); int y = sc.nextInt(); if (x == 0 && y == 0) { ret++; } else if (p == 0 && q == 0) { if (x == 0 && y == 0) { ret++; } } else if (p == 0) { if (x % q == 0 && y % q == 0) { ret++; } } else if (q == 0) { if (x % p == 0 && y % p == 0) { ret++; } } else if (p == q) { if (x % p == 0 && y % q == 0) { ret++; } } else { if (x % p == 0 && y % q == 0) { ret++; } else if (x % q == 0 && y % p == 0) { ret++; } else if (x - y != 0 && (x - y) % Math.abs(p - q) == 0) { ret++; } else if (x - y == 0 && x % (p + q) == 0) { ret++; } } } pr.println(ret); pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }