結果
| 問題 |
No.979 Longest Divisor Sequence
|
| コンテスト | |
| ユーザー |
utouto97
|
| 提出日時 | 2020-02-07 01:22:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 836 bytes |
| コンパイル時間 | 1,319 ms |
| コンパイル使用メモリ | 157,680 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-25 07:10:13 |
| 合計ジャッジ時間 | 5,203 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 TLE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:39:13: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
39 | scanf("%d", &a);
| ~^ ~~
| | |
| | long long int*
| int*
| %lld
main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d", &a);
| ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
/*
*/
using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int, int>;
int dp[301010];
signed main() {
int n;
cin >> n;
int ans = 0;
rep(i, 0, n){
int a;
scanf("%d", &a);
int ma = 1;
rep(j, 1, a/j+1) if(a%j == 0){
if(a != 1) chmax(ma, dp[j]+1);
if(j > 1) chmax(ma, dp[a/j]+1);
}
chmax(dp[a], ma);
chmax(ans, ma);
}
cout << ans << endl;
return 0;
}
utouto97