Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Main {
- public static void main(String[] args) throws IOException {
- // System.setIn(new FileInputStream(new File("/home/arif/Documents/inout/input.txt")));
- // System.setOut(new PrintStream(new File("/home/arif/Documents/inout/output.txt")));
- Scanner scanner = new Scanner(System.in);
- long[] arr = new long[30005];
- arr[1] = 1;
- for (int i=2;i<30002;i++)
- arr[i] = arr[i-1] + i;
- // System.out.println(arr[30001]);
- int tc = scanner.nextInt();
- while (tc-- >0) {
- long n = scanner.nextLong();
- long temp = n;
- while(temp%2==0)
- temp/=2;
- if(temp==1)
- System.out.println("IMPOSSIBLE");
- else {
- if (n%2==1)
- System.out.println(n + " = " + n/2 + " + " + n/2 + 1);
- else {
- int ind;
- for (ind=2;ind<30002;ind++)
- if ((n-arr[ind])%ind==0)
- break;
- long con = (n-arr[ind])/ind;
- System.out.print(n + " = ");
- int i;
- for (i=1;i<ind;i++)
- System.out.print(i+con + " + ");
- System.out.println(i+con);
- }
- }
- }
- scanner.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment