結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー cyclerecycle9cyclerecycle9
提出日時 2021-08-09 06:44:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,557 ms / 2,000 ms
コード長 3,800 bytes
コンパイル時間 2,146 ms
コンパイル使用メモリ 78,688 KB
実行使用メモリ 48,656 KB
最終ジャッジ日時 2024-10-03 02:58:00
合計ジャッジ時間 17,142 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,557 ms
47,180 KB
testcase_01 AC 606 ms
47,788 KB
testcase_02 AC 624 ms
48,032 KB
testcase_03 AC 600 ms
47,976 KB
testcase_04 AC 607 ms
47,932 KB
testcase_05 AC 601 ms
47,980 KB
testcase_06 AC 618 ms
48,036 KB
testcase_07 AC 601 ms
48,048 KB
testcase_08 AC 610 ms
48,152 KB
testcase_09 AC 629 ms
47,984 KB
testcase_10 AC 321 ms
47,256 KB
testcase_11 AC 352 ms
47,984 KB
testcase_12 AC 341 ms
47,716 KB
testcase_13 AC 337 ms
48,656 KB
testcase_14 AC 341 ms
48,084 KB
testcase_15 AC 346 ms
47,968 KB
testcase_16 AC 357 ms
48,112 KB
testcase_17 AC 339 ms
47,660 KB
testcase_18 AC 375 ms
48,028 KB
testcase_19 AC 70 ms
37,056 KB
testcase_20 AC 59 ms
37,096 KB
testcase_21 AC 71 ms
37,616 KB
testcase_22 AC 68 ms
37,436 KB
testcase_23 AC 62 ms
37,300 KB
testcase_24 AC 63 ms
37,472 KB
testcase_25 AC 69 ms
37,228 KB
testcase_26 AC 62 ms
37,012 KB
testcase_27 AC 72 ms
37,296 KB
testcase_28 AC 49 ms
36,544 KB
testcase_29 AC 49 ms
36,664 KB
testcase_30 AC 49 ms
36,988 KB
testcase_31 AC 49 ms
36,944 KB
testcase_32 AC 48 ms
36,980 KB
testcase_33 AC 46 ms
36,536 KB
testcase_34 AC 49 ms
36,768 KB
testcase_35 AC 48 ms
36,512 KB
testcase_36 AC 49 ms
36,844 KB
testcase_37 AC 49 ms
36,532 KB
testcase_38 AC 49 ms
37,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

public class Main {
	static final long MOD=1000000007;
	static final long MOD1=998244353;
	static int ans=0;
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int T = sc.nextInt();
		long[] prime = {2, 3, 5, 7, 11, 13, 17, 19,	23,	29,	31};
		for (int i = 0; i < T; i++) {
			long X = sc.nextLong();
			out.println(f(X, prime));
		}
		out.flush();
  	}
	static long f(long X,long[] prime) {
		long a = 1l;
		long X_ = X;
		for (int i = 0; i < prime.length; i++) {
			long a_=0;
			long p = prime[i];
			while (X_%p==0) {
				X_/=p;
				a_++;
			}
			a *= (a_ + 1l);
		}
		for (long i = 2; i <= 31; i++) {
			long b = 1;
			long cX = X*i;
			for (int j = 0; j < prime.length; j++) {
				long p = prime[j];
				long b_ = 0;
				while (cX%p==0) {
					cX/=p;
					b_++;
				}
				b *= (b_ + 1l);
			}
			if (b%a==0&&b/a==2) {
				return X*i;
			}
		}
		return -1;
	};
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
		public double[] nextDoubleArray(int n) {
			double[] a = new double[n];
			for (int i = 0; i < n; i++)
				a[i] = nextDouble();
			return a;
		}
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}
0