結果

問題 No.979 Longest Divisor Sequence
ユーザー kotatsugamekotatsugame
提出日時 2020-02-02 03:56:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 340 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 64,076 KB
実行使用メモリ 4,816 KB
最終ジャッジ日時 2023-10-19 00:34:45
合計ジャッジ時間 1,903 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
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 9 ms
4,816 KB
testcase_12 AC 9 ms
4,812 KB
testcase_13 WA -
testcase_14 AC 503 ms
4,816 KB
testcase_15 AC 169 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;
		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