結果

問題 No.979 Longest Divisor Sequence
ユーザー kotatsugamekotatsugame
提出日時 2020-02-02 03:57:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 607 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 570 ms
コンパイル使用メモリ 63,988 KB
実行使用メモリ 4,816 KB
最終ジャッジ日時 2023-10-19 00:34:47
合計ジャッジ時間 2,263 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 9 ms
4,816 KB
testcase_11 AC 10 ms
4,816 KB
testcase_12 AC 10 ms
4,812 KB
testcase_13 AC 46 ms
4,348 KB
testcase_14 AC 607 ms
4,816 KB
testcase_15 AC 201 ms
4,816 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
int dp[3<<17],ans;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;
		if(A==1)
		{
			dp[1]=1;
			if(ans<1)ans=1;
			continue;
		}
		int now=dp[1];
		for(int j=2;j*j<=A;j++)
		{
			if(A%j==0)
			{
				if(now<dp[j])now=dp[j];
				if(now<dp[A/j])now=dp[A/j];
			}
		}
		now++;
		if(dp[A]<now)dp[A]=now;
		if(ans<now)ans=now;
	}
	cout<<ans<<endl;
}
0