結果
| 問題 |
No.979 Longest Divisor Sequence
|
| ユーザー |
ttttan2
|
| 提出日時 | 2020-02-01 18:09:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 534 ms / 2,000 ms |
| コード長 | 1,721 bytes |
| コンパイル時間 | 1,521 ms |
| コンパイル使用メモリ | 161,520 KB |
| 実行使用メモリ | 35,840 KB |
| 最終ジャッジ日時 | 2024-09-18 20:09:28 |
| 合計ジャッジ時間 | 9,847 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
コンパイルメッセージ
main.cpp:18:11: warning: overflow in conversion from ‘long long int’ to ‘ll’ {aka ‘int’} changes value from ‘1152921504606846976’ to ‘0’ [-Woverflow]
18 | ll inf=1LL<<60;
| ~~~^~~~
ソースコード
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
if(a<b)swap(a,b);
if(b==0)return a;
if(a%b==0)return b;
return gcd(b,a%b);
}
ll Pow(ll n,ll k){
ll ret=1;
ll now=n;
while(k>0){
if(k&1)ret*=now;
now*=now;
k/=2;
}
return ret;
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n;cin>>n;
ll a[n];rep(i,0,n)cin>>a[i];
vector<ll> v[300001];
rep(i,2,300001){
v[i].push_back(1);
for(int j=2;j*j<=i;j++){
if(i%j==0){
v[i].push_back(j);
if(j*j<i)v[i].push_back(i/j);
}
}
}
int dp[300001];
fill(dp,dp+300001,0);
int ans=0;
rep(i,0,n){
int ma=0;
rep(j,0,v[a[i]].size()){
int ne=v[a[i]][j];
ma=max(ma,dp[ne]);
// cout<<ne<<" ";
}
//cout<<endl;
dp[a[i]]=ma+1;
ans=max(ans,dp[a[i]]);
}
cout<<ans<<endl;
}
ttttan2