Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- class Divisor {
- static FastReader sc;
- static PrintWriter out;
- public static void main(String[] args) {
- sc = new FastReader(new InputStreamReader(System.in));
- out = new PrintWriter(System.out);
- solve();
- out.flush();
- out.close();
- }
- static void solve() {
- int t = sc.nextInt();
- while (t-->0) {
- int x = sc.nextInt();
- int ans = 0;
- int ans1 = 0;
- for (int i = 1; i <=x; i++) {
- if(x%i==0){
- if(i%2==0){
- ans +=i;
- }else{
- ans1 +=i;
- }
- }
- }
- out.println(Math.abs(ans-ans1));
- }
- }
- /*************/
- static class FastReader {
- BufferedReader br;
- StringTokenizer st;
- public FastReader(Reader r) {
- br = new BufferedReader(r);
- }
- String next() {
- while (st == null || !st.hasMoreElements()) {
- try {
- st = new StringTokenizer(br.readLine());
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return st.nextToken();
- }
- int nextInt() {
- return Integer.parseInt(next());
- }
- long nextLong() {
- return Long.parseLong(next());
- }
- double nextDouble() {
- return Double.parseDouble(next());
- }
- int[] readArrayI(int n) {
- int[] arr = new int[n];
- for (int i = 0; i < n; i++) {
- arr[i] = sc.nextInt();
- }
- return arr;
- }
- long[] readArrayL(int n) {
- long[] arr = new long[n];
- for (int i = 0; i < n; i++) {
- arr[i] = sc.nextLong();
- }
- return arr;
- }
- String nextLine() {
- String str = "";
- try {
- str = br.readLine();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return str;
- }
- boolean hasNext() {
- if (st != null && st.hasMoreTokens()) {
- return true;
- }
- String tmp;
- try {
- br.mark(1000);
- tmp = br.readLine();
- if (tmp == null) {
- return false;
- }
- br.reset();
- } catch (IOException e) {
- return false;
- }
- return true;
- }
- }
- /*
- * ASCII Range--->(A-Z)--->[65,90]<<::>>(a-z)--->[97,122]
- */
- /**************/
- }
Add Comment
Please, Sign In to add comment