結果
問題 |
No.979 Longest Divisor Sequence
|
ユーザー |
![]() |
提出日時 | 2020-01-30 21:44:29 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,028 bytes |
コンパイル時間 | 2,799 ms |
コンパイル使用メモリ | 105,472 KB |
実行使用メモリ | 47,488 KB |
最終ジャッジ日時 | 2024-09-16 03:57:37 |
合計ジャッジ時間 | 3,390 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 3 |
コンパイルメッセージ
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{ static int ALim=300001; public static void Main() { int n=int.Parse(Console.ReadLine()); int[]a=Console.ReadLine().Split().Select(int.Parse).ToArray(); int[]dp=new int[ALim]; int[]exc=new int[ALim]; for(int i=0;i<ALim;i++){ dp[i]=-1; } int ans=0; while(true){ bool found=false; for(int i=0;i<ALim;i++)exc[i]=n; for(int i=1;i<ALim;i++){ for(int j=2*i;j<ALim;j+=i){ Chmin(ref exc[j], dp[i]); } } for(int i=0;i<ALim;i++)dp[i]=n; for(int i=0;i<n;i++)if(exc[a[i]]<i){ Chmin(ref dp[a[i]],i); found=true; } if(!found)break; ans++; } Console.WriteLine(ans); } public static void Chmin(ref int x, int y){ x=Math.Min(x,y); } }