結果

問題 No.2751 429-like Number
ユーザー tentententen
提出日時 2024-08-02 18:30:01
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,627 bytes
コンパイル時間 2,394 ms
コンパイル使用メモリ 85,768 KB
実行使用メモリ 60,400 KB
最終ジャッジ日時 2024-08-02 18:30:11
合計ジャッジ時間 10,312 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
57,872 KB
testcase_01 AC 68 ms
50,932 KB
testcase_02 AC 66 ms
50,784 KB
testcase_03 AC 70 ms
51,136 KB
testcase_04 AC 65 ms
51,084 KB
testcase_05 AC 68 ms
51,224 KB
testcase_06 AC 77 ms
51,644 KB
testcase_07 AC 141 ms
52,956 KB
testcase_08 AC 152 ms
53,008 KB
testcase_09 AC 216 ms
53,892 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        
        int q = sc.nextInt();
        String result = IntStream.range(0, q)
            .mapToObj(i -> calc(sc.nextLong()) ? "Yes" : "No")
            .collect(Collectors.joining("\n"));
        System.out.println(result);
    }
    
    static boolean calc(long x) {
        int count = 0;
        for (long i = 2; i <= Math.sqrt(x) && count <= 3; i++) {
            while (x % i == 0) {
                count++;
                x /= i;
            }
        }
        if (x > 1) {
            count++;
        }
        return count == 3;
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}


0