Language: Java

1. import java.util.*;
2. import java.io.*;
3.  
4. public class Main {
5.     public static void main(String[] args) throws Exception {
6.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7.         int N = Integer.parseInt(br.readLine());
8.         
9.         Map<List<Long>, List<Long>> mp = new HashMap<>();
10.         int zero = 0;
11.         int mod = 1000000007;
12.         for(int i = 0; i < N; i++) {
13.             String[] sp = br.readLine().split(" ");
14.             long x = Long.parseLong(sp[0]), y = Long.parseLong(sp[1]);
15.             if(x == 0 && y == 0) {
16.                 zero ++;
17.                 continue;
18.             }
19.             long g = gcd(x, y);
20.             x /= g; y /= g;
21.             if(x <= 0) {
22.                 long tmp = x;
23.                 x = y; y = -tmp;
24.                 List<Long> lk = new ArrayList<>();
25.                 lk.add(x); lk.add(y);
26.                 if(!mp.containsKey(lk)) {
27.                     List<Long> lv = new ArrayList<>();
28.                     lv.add(0L); lv.add(1L);
29.                     mp.put(lk, lv);
30.                 } else {
31.                     List<Long> l = mp.get(lk);
32.                     l.set(1,l.get(1)+1);
33.                     mp.put(lk, l);
34.                 }
35.             } else {
36.                 List<Long> lk = new ArrayList<>();
37.                 lk.add(x); lk.add(y);
38.                 if(!mp.containsKey(lk)) {
39.                     List<Long> lv = new ArrayList<>();
40.                     lv.add(1L); lv.add(0L);
41.                     mp.put(lk, lv);
42.                 } else {
43.                     List<Long> l = mp.get(lk);
44.                     l.set(0,l.get(0)+1);
45.                     mp.put(lk, l);
46.                 }
47.             }
48.         }
49.         // System.out.println(mp);
50.         
51.         long ans = 1;
52.         for(List<Long> q : mp.keySet()) {
53.             List<Long> p = mp.get(q);
54.             Long s = p.get(0);
55.             Long t = p.get(1);
56.             long now = 1;
57.             now += pow(2, s) - 1;
58.             now += pow(2, t) - 1;
59.             now %= mod;
60.             if(now < 0) now += mod;
61.             ans *= now;
62.             ans %= mod;
63.             if(ans < 0) ans += mod;
64.         }
65.         
66.         ans += zero;
67.         ans -= 1;
68.         ans %= mod;
69.         if(ans < 0) ans += mod;
70.         System.out.println(ans);
71.         
72.     }
73.     
74.     public static long gcd(long n1,long n2) {
75.         if(n2==0) return n1;
76.         else return gcd(n2,n1%n2);
77.     }
78.     
79.     public static long pow(long n1, long n2) {
80.         long p = 1;
81.         for(int i = 0; i < n2; i++) {
82.             p *= n1;
83.         }
84.         return p;
85.     }
86. }
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        
        Map<List<Long>, List<Long>> mp = new HashMap<>();
        int zero = 0;
        int mod = 1000000007;
        for(int i = 0; i < N; i++) {
            String[] sp = br.readLine().split(" ");
            long x = Long.parseLong(sp[0]), y = Long.parseLong(sp[1]);
            if(x == 0 && y == 0) {
                zero ++;
                continue;
            }
            long g = gcd(x, y);
            x /= g; y /= g;
            if(x <= 0) {
                long tmp = x;
                x = y; y = -tmp;
                List<Long> lk = new ArrayList<>();
                lk.add(x); lk.add(y);
                if(!mp.containsKey(lk)) {
                    List<Long> lv = new ArrayList<>();
                    lv.add(0L); lv.add(1L);
                    mp.put(lk, lv);
                } else {
                    List<Long> l = mp.get(lk);
                    l.set(1,l.get(1)+1);
                    mp.put(lk, l);
                }
            } else {
                List<Long> lk = new ArrayList<>();
                lk.add(x); lk.add(y);
                if(!mp.containsKey(lk)) {
                    List<Long> lv = new ArrayList<>();
                    lv.add(1L); lv.add(0L);
                    mp.put(lk, lv);
                } else {
                    List<Long> l = mp.get(lk);
                    l.set(0,l.get(0)+1);
                    mp.put(lk, l);
                }
            }
        }
        // System.out.println(mp);
        
        long ans = 1;
        for(List<Long> q : mp.keySet()) {
            List<Long> p = mp.get(q);
            Long s = p.get(0);
            Long t = p.get(1);
            long now = 1;
            now += pow(2, s) - 1;
            now += pow(2, t) - 1;
            now %= mod;
            if(now < 0) now += mod;
            ans *= now;
            ans %= mod;
            if(ans < 0) ans += mod;
        }
        
        ans += zero;
        ans -= 1;
        ans %= mod;
        if(ans < 0) ans += mod;
        System.out.println(ans);
        
    }
    
    public static long gcd(long n1,long n2) {
        if(n2==0) return n1;
        else return gcd(n2,n1%n2);
    }
    
    public static long pow(long n1, long n2) {
        long p = 1;
        for(int i = 0; i < n2; i++) {
            p *= n1;
        }
        return p;
    }
}


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
1. import java.util.*;
^
Main.java:2: error: class, interface, enum, or record expected
2. import java.io.*;
^
Main.java:3: error: class, interface, enum, or record expected
3. ?
^
Main.java:3: error: illegal character: '\u00a0'
3. ?
   ^
Main.java:5: error: illegal start of type
5.     public static void main(String[] args) throws Exception {
^
Main.java:6: error: not a statement
6.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
^
Main.java:6: error: ';' expected
6.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  ^
Main.java:7: error: not a statement
7.         int N = Integer.parseInt(br.readLine());
^
Main.java:7: error: ';' expected
7.         int N = Integer.parseInt(br.readLine());
  ^
Main.java:8: error: not a statement
8.         
^
Main.java:8: error: ';' expected
8.         
  ^
Main.java:10: error: not a statement
10.         int zero = 0;
^
Main.java:10: error: ';' expected
10.         int zero = 0;
   ^
Main.java:11: error: not a statement
11.         int mod = 1000000007;
^
Main.java:11: error: ';' expected
11.         int mod = 1000000007;
   ^
Main.java:12: error: not a statement
12.         for(int i = 0; i < N; i++) {
^
Main.java:12: error: ';' expected
12.         for(int i = 0; i < N; i++) {
   ^
Main.java:13: error: not a statement
13.             String[] sp = br.readLine().split(" ");
^
Main.java:13: error: ';' expected
13.             String[] sp = br.readLine().split(" ");
   ^
Main.java:14: error: not a statement
14.             long x = Long.parseLong(sp[0]), y = Long.parseLong(sp[1]);
^
Main.java:14: error: ';' expected
14.             long x = Long.parseLong(sp[0]), y = Long.parseLong(sp[1]);
   ^
Main.java:15: error: not a statement
15.             if(x == 0 && y == 0) {
^
Main.java:15: error: ';' expected
15.             if(x == 0 && y == 0) {
   ^
Main.java:16: error: not a statement
16.                 zero ++;
^
Main.java:16: error: ';' expected
16.                 zero ++;
   ^
Main.java:17: error: not a statement
17.                 continue;
^
Main.java:17: error: ';' expected
17.                 continue;
   ^
Main.java:18: error: not a statement
18.             }
^
Main.java:18: error: ';' expected
18.             }
   ^
Main.java:19: error: not a statement
19.             long g = gcd(x, y);
^
Main.java:19: error: ';' expected
19.             long g = gcd(x, y);
   ^
Main.java:20: error: not a statement
20.             x /= g; y /= g;
^
Main.java:20: error: ';' expected
20.             x /= g; y /= g;
   ^
Main.java:21: error: not a statement
21.             if(x <= 0) {
^
Main.java:21: error: ';' expected
21.             if(x <= 0) {
   ^
Main.java:22: error: not a statement
22.                 long tmp = x;
^
Main.java:22: error: ';' expected
22.                 long tmp = x;
   ^
Main.java:23: error: not a statement
23.                 x = y; y = -tmp;
^
Main.java:23: error: ';' expected
23.                 x = y; y = -tmp;
   ^
Main.java:24: error: not a statement
24.                 List<Long> lk = new ArrayList<>();
^
Main.java:24: error: ';' expected
24.                 List<Long> lk = new ArrayList<>();
   ^
Main.java:25: error: not a statement
25.                 lk.add(x); lk.add(y);
^
Main.java:25: error: ';' expected
25.                 lk.add(x); lk.add(y);
   ^
Main.java:26: error: not a statement
26.                 if(!mp.containsKey(lk)) {
^
Main.java:26: error: ';' expected
26.                 if(!mp.containsKey(lk)) {
   ^
Main.java:27: error: not a statement
27.                     List<Long> lv = new ArrayList<>();
^
Main.java:27: error: ';' expected
27.                     List<Long> lv = new ArrayList<>();
   ^
Main.java:28: error: not a statement
28.                     lv.add(0L); lv.add(1L);
^
Main.java:28: error: ';' expected
28.                     lv.add(0L); lv.add(1L);
   ^
Main.java:29: error: not a statement
29.                     mp.put(lk, lv);
^
Main.java:29: error: ';' expected
29.                     mp.put(lk, lv);
   ^
Main.java:30: error: not a statement
30.                 } else {
^
Main.java:30: error: ';' expected
30.                 } else {
   ^
Main.java:31: error: not a statement
31.                     List<Long> l = mp.get(lk);
^
Main.java:31: error: ';' expected
31.                     List<Long> l = mp.get(lk);
   ^
Main.java:32: error: not a statement
32.                     l.set(1,l.get(1)+1);
^
Main.java:32: error: ';' expected
32.                     l.set(1,l.get(1)+1);
   ^
Main.java:33: error: not a statement
33.                     mp.put(lk, l);
^
Main.java:33: error: ';' expected
33.                     mp.put(lk, l);
   ^
Main.java:34: error: not a statement
34.                 }
^
Main.java:34: error: ';' expected
34.                 }
   ^
Main.java:35: error: not a statement
35.             } else {
^
Main.java:35: error: ';' expected
35.             } else {
   ^
Main.java:36: error: not a statement
36.                 List<Long> lk = new ArrayList<>();
^
Main.java:36: error: ';' expected
36.                 List<Long> lk = new ArrayList<>();
   ^
Main.java:37: error: not a statement
37.                 lk.add(x); lk.add(y);
^
Main.java:37: error: ';' expected
37.                 lk.add(x); lk.add(y);
   ^
Main.java:38: error: not a statement
38.                 if(!mp.containsKey(lk)) {
^
Main.java:38: error: ';' expected
38.                 if(!mp.containsKey(lk)) {
   ^
Main.java:39: error: not a statement
39.                     List<Long> lv = new ArrayList<>();
^
Main.java:39: error: ';' expected
39.                     List<Long> lv = new ArrayList<>();
   ^
Main.java:40: error: not a statement
40.                     lv.add(1L); lv.add(0L);
^
Main.java:40: error: ';' expected
40.                     lv.add(1L); lv.add(0L);
   ^
Main.java:41: error: not a statement
41.                     mp.put(lk, lv);
^
Main.java:41: error: ';' expected
41.                     mp.put(lk, lv);
   ^
Main.java:42: error: not a statement
42.                 } else {
^
Main.java:42: error: ';' expected
42.                 } else {
   ^
Main.java:43: error: not a statement
43.                     List<Long> l = mp.get(lk);
^
Main.java:43: error: ';' expected
43.                     List<Long> l = mp.get(lk);
   ^
Main.java:44: error: not a statement
44.                     l.set(0,l.get(0)+1);
^
Main.java:44: error: ';' expected
44.                     l.set(0,l.get(0)+1);
   ^
Main.java:45: error: not a statement
45.                     mp.put(lk, l);
^
Main.java:45: error: ';' expected
45.                     mp.put(lk, l);
   ^
Main.java:46: error: not a statement
46.                 }
^
Main.java:46: error: ';' expected
46.                 }
   ^
Main.java:47: error: not a statement
47.             }
^
Main.java:47: error: ';' expected
47.             }
   ^
Main.java:48: error: not a statement
48.         }
^
Main.java:48: error: ';' expected
48.         }
   ^
Main.java:49: error: not a statement
49.         // System.out.println(mp);
^
Main.java:49: error: ';' expected
49.         // System.out.println(mp);
   ^
Main.java:52: error: not a statement
52.         for(List<Long> q : mp.keySet()) {
^
Main.java:52: error: ';' expected
52.         for(List<Long> q : mp.keySet()) {
   ^
Main.java:53: error: not a statement
53.             List<Long> p = mp.get(q);
^
Main.java:53: error: ';' expected
53.             List<Long> p = mp.get(q);
   ^
Main.java:54: error: not a statement
54.             Long s = p.get(0);
^
Main.java:54: error: ';' expected
54.             Long s = p.get(0);
   ^
Main.java:55: error: not a statement
55.             Long t = p.get(1);
^
Main.java:55: error: ';' expected
55.             Long t = p.get(1);
   ^
Main.java:56: error: not a statement
56.             long now = 1;
^
100 errors
only showing the first 100 errors, of 153 total; use -Xmaxerrs if you would like to see more