結果

問題 No.300 平方数
ユーザー nanophoto12
提出日時 2015-11-15 16:32:41
言語 Java
(openjdk 23)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 793 bytes
コンパイル時間 2,199 ms
コンパイル使用メモリ 74,916 KB
実行使用メモリ 61,788 KB
最終ジャッジ日時 2024-09-13 15:06:00
合計ジャッジ時間 8,281 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 TLE * 1 -- * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

package com.company;

import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long a = n;
        HashSet<Integer> hashSet = new HashSet<Integer>();
        for(int i = 2;i*i<=a;i++)
        {
            int count = 0;
            while(a % i == 0)
            {
                a /= i;
                count++;
            }
            if(count % 2 == 1)
            {
                hashSet.add(i);
            }
        }
        long y = 1;
        for(Integer element : hashSet)
        {
            y *= (long)element;
        }
        if(a != 1)
        {
            y*=a;
        }
        System.out.println(y);
    }
}
0