結果

問題 No.979 Longest Divisor Sequence
ユーザー ngtkanangtkana
提出日時 2020-01-30 20:05:55
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 842 bytes
コンパイル時間 1,655 ms
コンパイル使用メモリ 67,852 KB
実行使用メモリ 52,196 KB
最終ジャッジ日時 2023-10-14 08:41:53
合計ジャッジ時間 5,134 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
23,708 KB
testcase_01 AC 62 ms
23,624 KB
testcase_02 AC 61 ms
19,620 KB
testcase_03 AC 61 ms
21,580 KB
testcase_04 AC 60 ms
21,608 KB
testcase_05 AC 62 ms
23,668 KB
testcase_06 AC 61 ms
21,740 KB
testcase_07 AC 62 ms
21,784 KB
testcase_08 WA -
testcase_09 AC 61 ms
21,640 KB
testcase_10 AC 81 ms
22,528 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 143 ms
40,636 KB
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
    }
}
0