結果

問題 No.1999 Lattice Teleportation
ユーザー MasKoaTS
提出日時 2022-02-21 23:16:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 91,660 KB
最終ジャッジ日時 2024-11-08 11:06:15
合計ジャッジ時間 13,544 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def get_mod(n):
	if(n < 0):
		return mod - (-n) % mod
	return n % mod

def area(v1, v2):
	x1, y1 = get_mod(v1[0]), get_mod(v1[1])
	x2, y2 = get_mod(v2[0]), get_mod(v2[1])
	return get_mod(x1 * y2 % mod - x2 * y1 % mod)

def arg_sort(v1, v2):
	x1, y1 = v1
	x2, y2 = v2
	a1 = atan2(y1, x1)
	a2 = atan2(y2, x2)
	if(a1 > a2):
		return 1
	else:
		return -1

n = int(input())
v = []
for _ in [0] * n:
	x, y = map(int, input().split())
	if(y < 0):
		x = -x;		y = -y
	v.append((x, y))
v.sort(key = cmp_to_key(arg_sort))

if(n == 1):
	print((gcd(v[0][0], v[0][1]) + 1) % mod)
	exit(0)

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

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