結果

問題 No.1999 Lattice Teleportation
ユーザー MasKoaTSMasKoaTS
提出日時 2022-02-21 23:15:53
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 886 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 88,392 KB
最終ジャッジ日時 2024-04-25 22:57:30
合計ジャッジ時間 4,786 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 46 ms
56,336 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 45 ms
55,576 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#嘘解法

from functools import cmp_to_key
from math import gcd
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