|
| 1 | +package livecontest.Round728Div2; |
| 2 | + |
| 3 | +import java.io.PrintWriter; |
| 4 | +import java.io.BufferedReader; |
| 5 | +import java.io.InputStreamReader; |
| 6 | +import java.io.IOException; |
| 7 | +import java.util.StringTokenizer; |
| 8 | + |
| 9 | +public class B { |
| 10 | + |
| 11 | +public static void main(String[] args) { |
| 12 | + |
| 13 | +FastReader sc = new FastReader(); |
| 14 | +PrintWriter out = new PrintWriter(System.out); |
| 15 | + |
| 16 | +int t = sc.nextInt(); |
| 17 | +for (int tt = 0; tt < t; tt++) { |
| 18 | +int n = sc.nextInt(); |
| 19 | +int[] arr = sc.readArray(n); |
| 20 | +solveTask(arr); |
| 21 | +} |
| 22 | + |
| 23 | +out.close(); |
| 24 | +} |
| 25 | + |
| 26 | +private static void solveTask(int[] arr) { |
| 27 | +int count = 0; |
| 28 | + |
| 29 | +for (int i = 0; i < arr.length; i++) { |
| 30 | + |
| 31 | +for (int j = i + 1; j < arr.length; j++) { |
| 32 | + |
| 33 | +int ci = i + 1, cj = j + 1; |
| 34 | + |
| 35 | +if ((arr[i] * arr[j]) == (ci + cj)) |
| 36 | +count++; |
| 37 | +} |
| 38 | +} |
| 39 | +System.out.println(count); |
| 40 | +} |
| 41 | + |
| 42 | +static class FastReader { |
| 43 | +BufferedReader br; |
| 44 | +StringTokenizer st; |
| 45 | + |
| 46 | +FastReader() { |
| 47 | +br = new BufferedReader(new InputStreamReader(System.in)); |
| 48 | +} |
| 49 | + |
| 50 | +String next() { |
| 51 | +while (st == null || !st.hasMoreElements()) { |
| 52 | +try { |
| 53 | +st = new StringTokenizer(br.readLine()); |
| 54 | +} catch (IOException e) { |
| 55 | +e.printStackTrace(); |
| 56 | +} |
| 57 | +} |
| 58 | +return st.nextToken(); |
| 59 | +} |
| 60 | + |
| 61 | +int nextInt() { |
| 62 | +return Integer.parseInt(next()); |
| 63 | +} |
| 64 | + |
| 65 | +long nextLong() { |
| 66 | +return Long.parseLong(next()); |
| 67 | +} |
| 68 | + |
| 69 | +double nextDouble() { |
| 70 | +return Double.parseDouble(next()); |
| 71 | +} |
| 72 | + |
| 73 | +String nextLine() { |
| 74 | +String str = ""; |
| 75 | +try { |
| 76 | +str = br.readLine(); |
| 77 | +} catch (IOException e) { |
| 78 | +e.printStackTrace(); |
| 79 | +} |
| 80 | +return str; |
| 81 | +} |
| 82 | + |
| 83 | +int[] readArray(int n) { |
| 84 | +int[] temparr = new int[n]; |
| 85 | +for (int i = 0; i < n; i++) { |
| 86 | +temparr[i] = nextInt(); |
| 87 | +} |
| 88 | +return temparr; |
| 89 | +} |
| 90 | +} |
| 91 | +} |
0 commit comments