結果
問題 |
No.979 Longest Divisor Sequence
|
ユーザー |
![]() |
提出日時 | 2020-08-25 11:12:53 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 964 bytes |
コンパイル時間 | 2,234 ms |
コンパイル使用メモリ | 76,268 KB |
実行使用メモリ | 82,984 KB |
最終ジャッジ日時 | 2024-11-06 11:08:26 |
合計ジャッジ時間 | 10,409 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 2 TLE * 1 |
ソースコード
import java.util.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap<Integer, Integer> map = new HashMap<>(); int ans = 0; for (int i = 0; i < n; i++) { int x = sc.nextInt(); int max = 0; if (map.containsKey(1)) { max = map.get(1); } for (int j = 2; j <= Math.sqrt(x); j++) { if (x % j == 0) { if (map.containsKey(j)) { max = Math.max(max, map.get(j)); } if (map.containsKey(x / j)) { max = Math.max(max, map.get(x / j)); } } } map.put(x, max + 1); ans = Math.max(ans, max + 1); } System.out.println(ans); } }