其实数据开到1e3还是可以轻松通过的haha😁
思路
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e6 + 10; const ll mod = 1e9 + 7; struct edge{ int v, nex; }e[maxn << 1]; int a[110], cnt; double b[110]; int n, head[maxn]; ll dp[110]; void add_edge(int u, int v){ cnt++; e[cnt] = (edge){v, head[u]}; head[u] = cnt; } ll dfs(int u){ if(u == n + 1) return 1; if(dp[u]) return dp[u]; ll ans = 0; for(int i = head[u]; i > 0; i = e[i].nex){ ans += dfs(e[i].v); } return dp[u] = ans % mod; } int main(){ scanf("%d", &n); for(int i = 1; i <= n; i++){ scanf("%d", &a[i]); b[i] = log(a[i]) / (1.0 * i); } for(int i = 1; i <= n; i++) add_edge(0, i), add_edge(i, n + 1); for(int i = 1; i < n; i++){ for(int j = i + 1; j <= n; j++){ if(b[i] < b[j]) add_edge(i, j); } } printf("%lld\n", dfs(0)); return 0; }