結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー eitahoeitaho
提出日時 2016-01-09 20:50:52
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 2,565 bytes
コンパイル時間 2,753 ms
コンパイル使用メモリ 110,192 KB
実行使用メモリ 31,984 KB
最終ジャッジ日時 2023-09-21 03:28:25
合計ジャッジ時間 9,655 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
21,956 KB
testcase_01 AC 67 ms
21,896 KB
testcase_02 AC 66 ms
21,808 KB
testcase_03 AC 66 ms
21,944 KB
testcase_04 AC 66 ms
22,080 KB
testcase_05 AC 67 ms
23,932 KB
testcase_06 AC 66 ms
21,892 KB
testcase_07 AC 65 ms
19,896 KB
testcase_08 AC 66 ms
21,892 KB
testcase_09 AC 67 ms
24,028 KB
testcase_10 AC 66 ms
21,904 KB
testcase_11 AC 67 ms
21,916 KB
testcase_12 AC 67 ms
23,932 KB
testcase_13 AC 67 ms
19,912 KB
testcase_14 AC 141 ms
30,532 KB
testcase_15 AC 183 ms
31,984 KB
testcase_16 AC 112 ms
29,188 KB
testcase_17 AC 68 ms
22,060 KB
testcase_18 AC 122 ms
27,676 KB
testcase_19 AC 140 ms
30,272 KB
testcase_20 AC 178 ms
30,032 KB
testcase_21 AC 134 ms
27,772 KB
testcase_22 AC 86 ms
28,132 KB
testcase_23 AC 164 ms
29,348 KB
testcase_24 AC 91 ms
28,172 KB
testcase_25 AC 128 ms
29,864 KB
testcase_26 AC 173 ms
27,820 KB
testcase_27 AC 145 ms
28,680 KB
testcase_28 AC 145 ms
28,304 KB
testcase_29 AC 181 ms
29,944 KB
testcase_30 AC 69 ms
21,936 KB
testcase_31 AC 68 ms
22,092 KB
testcase_32 AC 126 ms
27,688 KB
testcase_33 AC 120 ms
27,600 KB
testcase_34 AC 108 ms
29,240 KB
testcase_35 AC 156 ms
30,852 KB
testcase_36 AC 70 ms
23,988 KB
testcase_37 AC 135 ms
30,272 KB
testcase_38 AC 123 ms
29,688 KB
testcase_39 AC 84 ms
28,196 KB
testcase_40 AC 173 ms
29,432 KB
testcase_41 AC 96 ms
26,624 KB
testcase_42 AC 156 ms
28,868 KB
testcase_43 AC 112 ms
27,160 KB
testcase_44 AC 146 ms
28,868 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

class Program
{
    public void Solve()
    {
        long P = Reader.Int(), Q = Reader.Int();
        int N = Reader.Int();
        var Pos = Reader.IntTable(N);
        long G = (long)BigInteger.GreatestCommonDivisor(P, Q);
        int ans = Pos.Count(p => Good(p[0], p[1], P, Q, G));
        Console.WriteLine(ans);
    }

    private bool Good(long X, long Y, long P, long Q, long G)
    {
        if (G == 0) return X == 0 && Y == 0;
        if (X % G != 0 || Y % G != 0) return false;
        X = Math.Abs(X) / G;
        Y = Math.Abs(Y) / G;
        if ((P + Q) / G % 2 == 0 && (X + Y) % 2 == 1) return false;
        return true;
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    private static TextReader reader = Console.In;
    private static readonly char[] separator = { ' ' };
    private static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    private static string[] A = new string[0];
    private static int i;
    private static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Enu.Range(0, N).Select(i => Int()).ToArray(); }
    public static int[][] IntTable(int H) { return Enu.Range(0, H).Select(i => IntLine()).ToArray(); }
    public static string[] StringArray(int N) { return Enu.Range(0, N).Select(i => Next()).ToArray(); }
    public static string Line() { return reader.ReadLine().Trim(); }
    private static string[] Split(string s) { return s.Split(separator, op); }
    private static string Next() { CheckNext(); return A[i++]; }
    private static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}
0