102最长因子链

102最长因子链

 

 

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 #define fi first
 4 #define se second
 5 #define go continue
 6 #define woc puts("");
 7 #define int long long
 8 #define PII pair<int, int>
 9 #define sf(x) scanf("%lld",&x)
10 #define ytz int _; sf(_); while(_--)
11 #define fory(i,a,b) for(int i = a; i <= b; ++i)
12 #define forl(i,a,b) for(int i = a; i >= b; --i)
13 #define debug(a) cout << #a << " = " << a <<endl;
14 const int N = 1010;
15 int n;
16 int a[N], f[N];
17 signed main()
18 {
19     sf(n);
20     fory(i, 1, n) sf(a[i]), f[i] = 1;
21     sort(a + 1, a + 1 + n);
22     fory(i, 1, n)
23     {
24         fory(j, i + 1, n)
25         {
26             if(a[j] % a[i] == 0) f[j] = max(f[j], f[i] + 1);
27         }
28     }
29     int ans = -1e18;
30     fory(i, 1, n) ans = max(ans, f[i]);
31     printf("%lld", ans);
32     return 0;
33 }

 

上一篇:ARK创始人:埃隆·马斯克和“ESG运动”是导致比特币下跌原因


下一篇:[975]python requests实现HTTPS客户端的证书导入