結果
問題 | No.321 (P,Q)-サンタと街の子供たち |
ユーザー | kou6839 |
提出日時 | 2015-12-14 00:33:25 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,042 bytes |
コンパイル時間 | 2,043 ms |
コンパイル使用メモリ | 73,596 KB |
実行使用メモリ | 65,708 KB |
最終ジャッジ日時 | 2023-10-13 15:09:07 |
合計ジャッジ時間 | 21,565 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | AC | 109 ms
55,440 KB |
testcase_02 | AC | 113 ms
56,048 KB |
testcase_03 | AC | 110 ms
56,308 KB |
testcase_04 | AC | 109 ms
55,724 KB |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | AC | 109 ms
55,604 KB |
testcase_09 | WA | - |
testcase_10 | AC | 120 ms
55,948 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 115 ms
56,072 KB |
testcase_14 | WA | - |
testcase_15 | AC | 661 ms
64,588 KB |
testcase_16 | RE | - |
testcase_17 | AC | 174 ms
56,036 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | RE | - |
testcase_23 | AC | 603 ms
64,796 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 678 ms
65,708 KB |
testcase_30 | AC | 191 ms
59,292 KB |
testcase_31 | WA | - |
testcase_32 | AC | 532 ms
60,436 KB |
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.net.NetworkInterface; import java.util.*; public class Main {public static int upper_bound(long[] arr, long key) { int len = arr.length; int lo = 0; int hi = len-1; int mid = (lo + hi)/2; while (true) { long cmp = arr[mid]-key; if (cmp == 0 || cmp < 0) { lo = mid+1; if (hi < lo) return mid<len-1?mid+1:-1; } else { hi = mid-1; if (hi < lo) return mid; } mid = (lo + hi)/2; } } static long gcd(long a,long b){ return b == 0 ? a : gcd(b, a%b); } static long lcm(long a, long b){ return a*b/gcd(a, b); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int p = sc.nextInt(); int q = sc.nextInt(); int n = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; for(int i=0;i<n;i++){ x[i] = sc.nextInt(); y[i] = sc.nextInt(); } if(gcd(p, q)==1){ System.out.println(n); }else{ int ans =0; for(int i=0;i<n;i++){ if(x[i]%p==0 && y[i]%q==0 || x[i]%q==0 && y[i]%p==0) ans++; } System.out.println(ans); } } }