結果

問題 No.1999 Lattice Teleportation
ユーザー tnodinotnodino
提出日時 2022-07-03 01:14:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 695 ms / 2,000 ms
コード長 707 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 90,088 KB
最終ジャッジ日時 2023-08-18 18:17:47
合計ジャッジ時間 13,983 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,212 KB
testcase_01 AC 69 ms
71,352 KB
testcase_02 AC 64 ms
71,168 KB
testcase_03 AC 66 ms
71,504 KB
testcase_04 AC 71 ms
71,232 KB
testcase_05 AC 91 ms
75,768 KB
testcase_06 AC 90 ms
75,924 KB
testcase_07 AC 77 ms
75,620 KB
testcase_08 AC 69 ms
71,488 KB
testcase_09 AC 65 ms
71,580 KB
testcase_10 AC 70 ms
71,448 KB
testcase_11 AC 91 ms
76,088 KB
testcase_12 AC 529 ms
89,912 KB
testcase_13 AC 695 ms
90,088 KB
testcase_14 AC 68 ms
71,420 KB
testcase_15 AC 684 ms
89,968 KB
testcase_16 AC 398 ms
84,316 KB
testcase_17 AC 617 ms
88,476 KB
testcase_18 AC 548 ms
87,304 KB
testcase_19 AC 567 ms
88,040 KB
testcase_20 AC 674 ms
89,828 KB
testcase_21 AC 648 ms
89,936 KB
testcase_22 AC 648 ms
89,744 KB
testcase_23 AC 143 ms
78,460 KB
testcase_24 AC 278 ms
82,152 KB
testcase_25 AC 557 ms
87,796 KB
testcase_26 AC 476 ms
85,812 KB
testcase_27 AC 403 ms
84,436 KB
testcase_28 AC 641 ms
89,000 KB
testcase_29 AC 345 ms
83,080 KB
testcase_30 AC 201 ms
80,248 KB
testcase_31 AC 177 ms
79,720 KB
testcase_32 AC 412 ms
84,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
mod = 10**9+7
class Point:
    def __init__(self, px, py):
        self.px = px
        self.py = py

    def __lt__(self, other):
        return crs(self, other) > 0

def crs(p1, p2):
    return p1.px * p2.py - p1.py * p2.px

N = int(input())
vec = []
for _ in range(N):
    A,B = map(int,input().split())
    if A == 0 and B == 0:
        continue
    if B < 0:
        A *= -1
        B *= -1
    vec.append(Point(A, B))
vec.sort()

EdgePoint = 0
Area = 0
x,y = 0,0
for v in vec:
    a = Point(x, y)
    b = Point(x+v.px, y+v.py)
    Area += crs(a, b)
    Area %= mod
    EdgePoint += gcd(v.px, v.py)
    EdgePoint %= mod
    x = b.px
    y = b.py
print((Area + EdgePoint + 1) % mod)
0