結果
問題 | No.312 置換処理 |
ユーザー |
![]() |
提出日時 | 2016-06-10 01:38:58 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 77 ms / 2,000 ms |
コード長 | 746 bytes |
コンパイル時間 | 3,671 ms |
コンパイル使用メモリ | 74,764 KB |
実行使用メモリ | 37,748 KB |
最終ジャッジ日時 | 2024-11-15 12:07:42 |
合計ジャッジ時間 | 7,429 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 45 |
ソースコード
import java.util.*; import java.io.*; public class Exercise75{ public static void main (String[] args) throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String nStr = new String(in.readLine()); long nd = Long.parseLong(nStr); long n = nd; long[] factor = new long[20]; int count = 0; for (long i = 3; i * i <= n; i ++){ if(n % i == 0){ while (n % i == 0){ factor[count] = i; n /= i; } count++; } } if (factor[0] > 2){ System.out.println(factor[0]); }else{ if(n % 2 == 0 && n / 2 != 2){ System.out.println(n / 2); }else{ System.out.println(n); } } } }