結果

問題 No.1999 Lattice Teleportation
ユーザー MasKoaTSMasKoaTS
提出日時 2022-06-23 17:06:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,022 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2024-04-25 23:01:26
合計ジャッジ時間 15,695 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 33 ms
10,880 KB
testcase_05 AC 34 ms
11,008 KB
testcase_06 AC 34 ms
11,008 KB
testcase_07 AC 32 ms
11,008 KB
testcase_08 AC 30 ms
10,880 KB
testcase_09 AC 28 ms
10,880 KB
testcase_10 AC 27 ms
10,752 KB
testcase_11 AC 33 ms
11,008 KB
testcase_12 AC 827 ms
26,752 KB
testcase_13 AC 1,021 ms
26,752 KB
testcase_14 AC 30 ms
10,752 KB
testcase_15 AC 1,012 ms
26,624 KB
testcase_16 AC 518 ms
18,816 KB
testcase_17 AC 905 ms
23,936 KB
testcase_18 AC 793 ms
22,400 KB
testcase_19 AC 859 ms
23,040 KB
testcase_20 AC 1,022 ms
26,752 KB
testcase_21 AC 1,010 ms
26,624 KB
testcase_22 AC 1,001 ms
26,752 KB
testcase_23 AC 81 ms
11,776 KB
testcase_24 AC 309 ms
15,744 KB
testcase_25 AC 774 ms
22,400 KB
testcase_26 AC 636 ms
20,224 KB
testcase_27 AC 538 ms
18,688 KB
testcase_28 AC 945 ms
24,320 KB
testcase_29 AC 422 ms
17,280 KB
testcase_30 AC 183 ms
13,696 KB
testcase_31 AC 144 ms
12,928 KB
testcase_32 AC 580 ms
19,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
import sys
input = sys.stdin.readline
mod = 10 ** 9 + 7

class Vector2:
	def __init__(self, x: int, y: int):
		self.x = x
		self.y = y

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

def area(v1: Vector2, v2: Vector2) -> int:
	return v1.x * v2.y - v1.y * v2.x


n = int(input())
vector = []
for _ in [0] * n:
	x, y = map(int, input().split())
	if(x == 0 and y == 0):
		continue
	if(y < 0):
		x = -x
		y = -y
	vector.append(Vector2(x, y))
vector.sort()

S, bh = 0, 0
lx, ly = 0, 0
for v in vector:
	v1 = Vector2(lx, ly)
	v2 = Vector2(lx + v.x, ly + v.y)
	S += area(v1, v2) % mod
	S %= mod
	bh += gcd(v.x, v.y)
	bh %= mod
	lx, ly = v2.x, v2.y

ans = (S + bh + 1) % mod
print(ans)
0