結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー eitahoeitaho
提出日時 2016-01-09 20:39:03
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,509 bytes
コンパイル時間 1,320 ms
コンパイル使用メモリ 114,652 KB
実行使用メモリ 33,264 KB
最終ジャッジ日時 2023-10-19 16:58:37
合計ジャッジ時間 6,161 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
25,712 KB
testcase_01 AC 33 ms
25,712 KB
testcase_02 AC 33 ms
25,712 KB
testcase_03 AC 32 ms
25,712 KB
testcase_04 AC 32 ms
25,712 KB
testcase_05 AC 32 ms
25,708 KB
testcase_06 AC 33 ms
25,708 KB
testcase_07 AC 33 ms
25,708 KB
testcase_08 AC 33 ms
25,708 KB
testcase_09 AC 33 ms
25,708 KB
testcase_10 AC 34 ms
25,708 KB
testcase_11 WA -
testcase_12 AC 34 ms
25,708 KB
testcase_13 AC 32 ms
25,708 KB
testcase_14 AC 112 ms
31,992 KB
testcase_15 AC 155 ms
33,264 KB
testcase_16 AC 81 ms
30,492 KB
testcase_17 AC 34 ms
25,708 KB
testcase_18 AC 91 ms
31,024 KB
testcase_19 WA -
testcase_20 AC 152 ms
33,252 KB
testcase_21 WA -
testcase_22 AC 53 ms
29,840 KB
testcase_23 AC 133 ms
32,672 KB
testcase_24 AC 58 ms
29,840 KB
testcase_25 WA -
testcase_26 AC 146 ms
33,224 KB
testcase_27 WA -
testcase_28 AC 116 ms
31,640 KB
testcase_29 AC 154 ms
33,264 KB
testcase_30 AC 35 ms
25,708 KB
testcase_31 AC 34 ms
25,708 KB
testcase_32 AC 95 ms
31,044 KB
testcase_33 WA -
testcase_34 AC 77 ms
30,464 KB
testcase_35 WA -
testcase_36 AC 37 ms
25,708 KB
testcase_37 AC 106 ms
31,576 KB
testcase_38 AC 93 ms
31,024 KB
testcase_39 WA -
testcase_40 AC 145 ms
32,748 KB
testcase_41 WA -
testcase_42 AC 129 ms
32,192 KB
testcase_43 AC 80 ms
30,488 KB
testcase_44 AC 119 ms
32,136 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(int X, int Y, long P, long Q, long G)
    {
        if (G == 0) return X == 0 && Y == 0;
        if (X % G != 0 || Y % G != 0) return false;
        if ((P + Q) / G % 2 == 0 && (X + Y) / G % 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