結果

問題 No.300 平方数
ユーザー spaciaspacia
提出日時 2016-01-12 23:33:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,084 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 78,012 KB
実行使用メモリ 54,812 KB
最終ジャッジ日時 2023-10-19 22:55:53
合計ジャッジ時間 7,010 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
53,536 KB
testcase_01 AC 57 ms
53,548 KB
testcase_02 AC 72 ms
54,280 KB
testcase_03 AC 57 ms
52,448 KB
testcase_04 AC 56 ms
53,536 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 56 ms
53,532 KB
testcase_08 AC 56 ms
53,536 KB
testcase_09 AC 57 ms
53,540 KB
testcase_10 AC 65 ms
53,548 KB
testcase_11 AC 57 ms
53,544 KB
testcase_12 AC 56 ms
52,476 KB
testcase_13 WA -
testcase_14 AC 58 ms
53,544 KB
testcase_15 AC 68 ms
54,220 KB
testcase_16 AC 66 ms
54,104 KB
testcase_17 AC 73 ms
54,256 KB
testcase_18 AC 58 ms
51,492 KB
testcase_19 AC 65 ms
52,920 KB
testcase_20 WA -
testcase_21 AC 73 ms
53,556 KB
testcase_22 AC 72 ms
54,220 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 83 ms
54,104 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 72 ms
54,228 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 64 ms
53,536 KB
testcase_34 AC 72 ms
54,240 KB
testcase_35 AC 71 ms
54,612 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 75 ms
54,236 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 80 ms
54,220 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static boolean isPrime (long n) {
		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0) return false;
		}
		return true;
	}
	
	public static long solve (long n) {
		int max = 12 , m = 0;
		long[] p = new long[max];
		int[] cntP = new int[max];
		
		if (n % 2 == 0) {
			long k = n;
			p[m] = 2;
			while (k % 2 == 0) {
				k /= 2;
				cntP[m]++;
			}
			m++;
		}
		
		long q = n;
		for (long i = 3; i * i <= n; i += 2) {
			if (q % i == 0) {
				p[m] = i;
				while (q % i == 0) {
					q /= i;
					cntP[m]++;
				}
				m++;
			}
		}
		
		if (m == 0) return n;
		
		//out(Arrays.toString(p));
		//out(Arrays.toString(cntP));
		
		long ret = 1;
		for (int i = 0; i < m; i++) {
			if (cntP[i] % 2 == 0) continue;
			ret *= p[i];
		}
		
		return ret;
	}
	
	public static void main (String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		out(solve(Long.parseLong(br.readLine())));
	}
}
0