結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー GrenacheGrenache
提出日時 2015-12-14 00:46:06
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,559 bytes
コンパイル時間 3,322 ms
コンパイル使用メモリ 75,020 KB
実行使用メモリ 59,852 KB
最終ジャッジ日時 2023-10-13 15:11:11
合計ジャッジ時間 11,922 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
49,844 KB
testcase_01 AC 39 ms
49,336 KB
testcase_02 AC 43 ms
49,472 KB
testcase_03 AC 41 ms
49,348 KB
testcase_04 AC 41 ms
49,476 KB
testcase_05 AC 42 ms
49,548 KB
testcase_06 AC 42 ms
47,912 KB
testcase_07 AC 41 ms
49,340 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 42 ms
49,384 KB
testcase_11 AC 40 ms
49,456 KB
testcase_12 WA -
testcase_13 AC 41 ms
49,400 KB
testcase_14 WA -
testcase_15 AC 306 ms
58,108 KB
testcase_16 AC 180 ms
55,828 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 142 ms
55,592 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = Math.abs(sc.nextInt());
        	int y = Math.abs(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 - y) % (2 * p) == 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);
		}
	}
}
0