0_0_29469414_21023.cpp:1:1: error: 'import' does not name a type
import java.util.Scanner;import java.math.BigInteger; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigInteger[] a; a = new BigInteger[3017]; int t, n; t = cin.nextInt(); while(t--){ n = cin.nextInt(); for (int i = 0; i < n; i++) a[i] = cin.nextBigInteger(); BigInteger ans = BigInteger.ZERO; BigInteger c = BigInteger.ONE; for (int i = 0; i < n; i++) { BigInteger tmp = c.multiply(a[n-i-1]); if (i%2 == 0) ans = ans.add(tmp); else ans = ans.subtract(tmp); tmp = c.multiply(BigInteger.valueOf(n-i-1)); c = tmp.divide(BigInteger.valueOf(i+1)); } System.out.println(ans); } } }
^
0_0_29469414_21023.cpp:1:26: error: 'import' does not name a type
import java.util.Scanner;import java.math.BigInteger; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigInteger[] a; a = new BigInteger[3017]; int t, n; t = cin.nextInt(); while(t--){ n = cin.nextInt(); for (int i = 0; i < n; i++) a[i] = cin.nextBigInteger(); BigInteger ans = BigInteger.ZERO; BigInteger c = BigInteger.ONE; for (int i = 0; i < n; i++) { BigInteger tmp = c.multiply(a[n-i-1]); if (i%2 == 0) ans = ans.add(tmp); else ans = ans.subtract(tmp); tmp = c.multiply(BigInteger.valueOf(n-i-1)); c = tmp.divide(BigInteger.valueOf(i+1)); } System.out.println(ans); } } }
^
0_0_29469414_21023.cpp:1:55: error: expected unqualified-id before 'public'
import java.util.Scanner;import java.math.BigInteger; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigInteger[] a; a = new BigInteger[3017]; int t, n; t = cin.nextInt(); while(t--){ n = cin.nextInt(); for (int i = 0; i < n; i++) a[i] = cin.nextBigInteger(); BigInteger ans = BigInteger.ZERO; BigInteger c = BigInteger.ONE; for (int i = 0; i < n; i++) { BigInteger tmp = c.multiply(a[n-i-1]); if (i%2 == 0) ans = ans.add(tmp); else ans = ans.subtract(tmp); tmp = c.multiply(BigInteger.valueOf(n-i-1)); c = tmp.divide(BigInteger.valueOf(i+1)); } System.out.println(ans); } } }
^
|