結果

問題 No.1999 Lattice Teleportation
ユーザー MasKoaTS
提出日時 2022-06-23 17:06:54
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,142 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 26,624 KB
最終ジャッジ日時 2024-11-08 11:10:13
合計ジャッジ時間 16,986 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

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