Submission #19514885


Source Code Expand

Copy
from collections import defaultdict
import math
mod=10**9+7
n=int(input())
P=defaultdict(int)
M=defaultdict(int)
s=set()
c=0
for _ in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        c+=1
        continue
    elif a==0:
        s.add((0,1))
        P[(0,1)]+=1
        continue
    elif b==0:
        s.add((0,1))
        M[(0,1)]+=1
        continue
    g=math.gcd(a,b)
    a,b=a//g,b//g
    if a*b<0:
        s.add((abs(b),abs(a)))
        M[(abs(b),abs(a))]+=1
    else:
        s.add((abs(a),abs(b)))
        P[(abs(a),abs(b))]+=1
D_pow=dict()
def my_pow(k):
    if k in D_pow:
        return D_pow[k]
    else:
        D_pow[k]=pow(2,k,mod)
        return D_pow[k]
ans=1
for k in s:
    tmp=my_pow(P[k])+my_pow(M[k])-1
    tmp%=mod
    ans*=tmp
    ans%=mod
ans=(ans+c-1)%mod
print(ans)

Submission Info

Submission Time
Task E - ∙ (Bullet)
User bis
Language PyPy3 (7.3.0)
Score 500
Code Size 858 Byte
Status AC
Exec Time 679 ms
Memory 181556 KB

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 23
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
Subtask1 sample_01.txt, sample_02.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt
Case Name Status Exec Time Memory
sample_01.txt AC 77 ms 65508 KB
sample_02.txt AC 57 ms 65452 KB
sub1_01.txt AC 679 ms 181556 KB
sub1_02.txt AC 56 ms 65296 KB
sub1_03.txt AC 59 ms 65348 KB
sub1_04.txt AC 58 ms 65404 KB
sub1_05.txt AC 57 ms 65540 KB
sub1_06.txt AC 56 ms 65588 KB
sub1_07.txt AC 56 ms 65236 KB
sub1_08.txt AC 57 ms 65316 KB
sub1_09.txt AC 59 ms 65452 KB
sub1_10.txt AC 57 ms 65324 KB
sub1_11.txt AC 259 ms 73288 KB
sub1_12.txt AC 433 ms 78608 KB
sub1_13.txt AC 582 ms 81060 KB
sub1_14.txt AC 389 ms 71936 KB
sub1_15.txt AC 156 ms 70356 KB
sub1_16.txt AC 390 ms 76648 KB
sub1_17.txt AC 256 ms 70616 KB
sub1_18.txt AC 349 ms 70456 KB
sub1_19.txt AC 187 ms 86380 KB
sub1_20.txt AC 363 ms 131232 KB
sub1_21.txt AC 253 ms 69948 KB