結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
ngtkana
|
| 提出日時 | 2020-01-30 20:05:55 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 842 bytes |
| コンパイル時間 | 4,065 ms |
| コンパイル使用メモリ | 115,404 KB |
| 実行使用メモリ | 56,024 KB |
| 最終ジャッジ日時 | 2024-09-16 03:49:15 |
| 合計ジャッジ時間 | 5,274 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 5 |
コンパイルメッセージ
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++){
Chmax(ref dp[x], dp[d]+1);
if(d!=1&&d*d!=x){
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