static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var ab = new double[N, 2]; for (int i = 0; i < N; i++) { var read = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse); ab[i, 0] = read[0]; ab[i, 1] = read[1]; } long MOD = 1000000007; var ratio = new ElementCounter <double>(); for (int i = 0; i < N; i++) { ratio.Add((double)ab[i, 0] / (double)ab[i, 1]); } long result = 0; for (int i = 0; i < N; i++) { result += modPow(2, N - ratio[-1 * (double)ab[i, 1] / (double)ab[i, 0]] - i - 1, MOD); result %= MOD; ratio.Remove((double)ab[i, 0] / (double)ab[i, 1]); } Console.WriteLine(result - 1); }
static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); var reverseA = A.Reverse().ToArray(); long result = 0; for (int i = 0; i < N; i++) { A[i] = A[i] - i; } var counter1 = new ElementCounter <long>(); foreach (long a in A) { counter1.Add(a); } foreach (long k in counter1.Dic.Keys) { if (k <= 0) { continue; } if (counter1.Dic.ContainsKey(-k)) { result += counter1.Dic[k] * counter1.Dic[-k]; } } for (int i = 0; i < N; i++) { reverseA[i] = reverseA[i] - i; } var counter2 = new ElementCounter <long>(); foreach (long a in reverseA) { counter2.Add(a); } foreach (long k in counter2.Dic.Keys) { if (k <= 0) { continue; } if (counter2.Dic.ContainsKey(-k)) { result += counter2.Dic[k] * counter2.Dic[-k]; } } Console.WriteLine(result); }