結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
ngtkana
|
| 提出日時 | 2020-01-30 20:08:02 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 658 ms / 2,000 ms |
| コード長 | 870 bytes |
| コンパイル時間 | 840 ms |
| コンパイル使用メモリ | 105,856 KB |
| 実行使用メモリ | 47,872 KB |
| 最終ジャッジ日時 | 2024-09-16 03:49:18 |
| 合計ジャッジ時間 | 2,947 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
using System.Collections.Generic;
public static class Program{
public static void Main() {
int n=int.Parse(Console.ReadLine());
int[]a=Console.ReadLine().Split().Select(int.Parse).ToArray();
int[]dp=new int[300001];
for(int i=0;i<n;i++){
int x=a[i];
if(x==1){
dp[1]=1;
continue;
}
for(int d=1;d*d<=x;d++){
if(x%d!=0)continue;
Chmax(ref dp[x], dp[d]+1);
if(d!=1){
Chmax(ref dp[x], dp[x/d]+1);
}
}
}
int ans=0;
for(int i=0;i<=300000;i++){
Chmax(ref ans, dp[i]);
}
Console.WriteLine(ans);
}
public static void Chmax(ref int x, int y){
x=Math.Max(x,y);
}
}
ngtkana