CSP202104-4校门外的树
`#include
include
include
include
include
include
include
include
include
include
include
include
using namespace std;
define MX Maxn + 5
define LS p<<1
define RS p<<1|1
typedef long long ll;
define rep_(i,a,b) for(int i=(a); i<(b); ++i)
define for_(i,a,b) for(int i=(a); i<=(b); ++i)
define dwn_(i,a,b) for(int i=(a); i>=(b); --i)
inline void chkmax(int &x,int y) {if(x<y) x=y;}
inline void chkmin(int &x,int y) {if(x>y) x=y;}
const int Maxn = 100000;
ll P = 1e9+7, inf = 0x3f3f3f3f;
const ll Inf = 0x3f3f3f3f3f3f3f3fll;
int N, M, T, RT, cnt ;
int a[1005]; ll f[1005]; int vis[100005];
ll cal(int d, int id) {
ll res = 0;
for_(i,1,sqrt(d)) {
if(d % i == 0) {
if(vis[i] != id) ++res,vis[i] = id;
if(vis[d/i] != id) ++res,vis[d/i] = id;
res %= P;
}
}
return (res - 1 + P) % P;
}
int main()
{
cin >> N;
for_(i,1,N) cin >> a[i];
f[1] = 1;
for_(i,1,N)
dwn_(j, i - 1, 1)
f[i] = (f[j] * cal(a[i] - a[j], i) % P + f[i]) % P;
cout << f[N];
return 0;
}
`