結果
問題 | No.849 yuki国の分割統治 |
ユーザー | convexineq |
提出日時 | 2019-07-05 22:19:13 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 450 ms / 2,000 ms |
コード長 | 970 bytes |
コンパイル時間 | 318 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 43,228 KB |
最終ジャッジ日時 | 2024-10-06 22:09:54 |
合計ジャッジ時間 | 9,735 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
# coding: utf-8 # Your code here! import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline #文字列入力のときは注意 from math import gcd a,b,c,d = [int(i) for i in readline().split()] n = int(input()) xy = [[int(i) for i in readline().split()] for _ in range(n)] def heikouidou(x,y,pp,qq,g,h): #(e,f)に沿って(g,h)以上のぎりぎり m = (x*h-y*g)//(h*pp-g*qq) x -= m*pp y-= m*qq return (x,y) if a*d == b*c: if a==0 and c==0: g = gcd(b,d) p,q = a//(b//g), g else: g = gcd(a,c) p,q = g, b//(a//g) # print(a,b,c,d,g) # assert b%g==0 s = set() for x,y in xy: s.add(heikouidou(x,y,p,q,-q,p)) print(len(s)) # print(s) exit() s = set() for x,y in xy: # print(x,y) x,y = heikouidou(x,y,a,b,c,d) # print(x,y) x,y = heikouidou(x,y,c,d,a,b) # print(x,y) s.add((x,y)) print(len(s)) #print(s) exit()