結果
| 問題 |
No.889 素数!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-16 16:30:02 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 2,000 ms |
| コード長 | 1,312 bytes |
| コンパイル時間 | 2,079 ms |
| コンパイル使用メモリ | 77,492 KB |
| 実行使用メモリ | 50,444 KB |
| 最終ジャッジ日時 | 2024-07-07 02:25:38 |
| 合計ジャッジ時間 | 7,169 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 61 |
ソースコード
import java.io.*;
public class Main{
static boolean isPrime(int x){
if(x < 2) return false;
for(int i = 2; i < x; i++){
if(x % i == 0) return false;
}
return true;
}
static boolean isSquare(int x){
for(int i = 1; i*i <= x; i++){
if(i*i == x) return true;
}
return false;
}
static boolean isCubic(int x){
for(int i = 1; i*i*i <= x; i++){
if(i*i*i == x) return true;
}
return false;
}
static boolean isPerfect(int x){
int sum = 0;
for(int i = 1; i <= x; i++){
if(x%i == 0) sum += i;
}
return (sum == x+x);
}
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int n = Integer.parseInt(line);
String ans = "";
if(n < 2) ans = String.valueOf(n);
else if(isPrime(n)) ans = "Sosu!";
else if(isSquare(n)) ans = "Heihosu!";
else if(isCubic(n)) ans = "Ripposu!";
else if(isPerfect(n)) ans = "Kanzensu!";
else ans = String.valueOf(n);
System.out.println(ans);
}
}