結果

問題 No.1999 Lattice Teleportation
ユーザー MasKoaTSMasKoaTS
提出日時 2022-02-21 22:45:24
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 886 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 82,528 KB
実行使用メモリ 91,564 KB
最終ジャッジ日時 2024-04-25 22:56:37
合計ジャッジ時間 11,773 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
56,824 KB
testcase_01 AC 44 ms
55,964 KB
testcase_02 AC 44 ms
55,700 KB
testcase_03 AC 45 ms
55,972 KB
testcase_04 AC 47 ms
58,004 KB
testcase_05 AC 61 ms
71,384 KB
testcase_06 AC 61 ms
70,564 KB
testcase_07 AC 56 ms
66,968 KB
testcase_08 AC 48 ms
58,704 KB
testcase_09 AC 43 ms
55,620 KB
testcase_10 AC 43 ms
57,028 KB
testcase_11 AC 63 ms
73,628 KB
testcase_12 AC 487 ms
90,984 KB
testcase_13 AC 680 ms
90,944 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 382 ms
85,824 KB
testcase_17 AC 618 ms
90,040 KB
testcase_18 AC 525 ms
88,832 KB
testcase_19 AC 582 ms
89,344 KB
testcase_20 AC 679 ms
91,164 KB
testcase_21 AC 687 ms
91,564 KB
testcase_22 AC 674 ms
90,960 KB
testcase_23 AC 112 ms
78,448 KB
testcase_24 AC 245 ms
82,284 KB
testcase_25 AC 545 ms
89,072 KB
testcase_26 AC 450 ms
85,728 KB
testcase_27 AC 378 ms
85,896 KB
testcase_28 AC 587 ms
90,912 KB
testcase_29 AC 317 ms
83,780 KB
testcase_30 AC 173 ms
79,652 KB
testcase_31 AC 150 ms
78,824 KB
testcase_32 AC 413 ms
86,552 KB
権限があれば一括ダウンロードができます

ソースコード

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
	if(x1 * y2 == x2 * y1):
		return 0
	elif(x1 * y2 - x2 * y1 < 0):
		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