标签:href col Beginner c++ begin for http make names
思路:
整除分块+dp
打表发现,按整除分块后转移方向如下图所示,上面的块的前缀转移到下面的块
代码:
#pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define y1 y11Z #define se second #define pi acos(-1.0) #define LL long long //#define mp make_pair #define pb push_back #define ls rt<<1, l, m #define rs rt<<1|1, m+1, r #define ULL unsigned LL #define pll pair<LL, LL> #define pli pair<LL, int> #define pii pair<int, int> #define piii pair<int, pii> #define puu pair<ULL, ULL> #define MOD(a, b) (a >= b ? a%b+b : a%b) #define pdd pair<long double, long double> #define mem(a, b) memset(a, b, sizeof(a)) #define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout); //head const int N = 1e5 + 5; const int MOD = 1e9 + 7; int n, k, l[N], r[N], cnt = 0; int dp[105][N]; int main() { scanf("%d %d", &n, &k); for (int x = 1, y; x <= n; x = y+1) { y = n/(n/x); l[++cnt] = x; r[cnt] = y; } for (int i = 1; i <= cnt; ++i) dp[1][i] = (dp[1][i-1] + r[i]-l[i]+1)%MOD; for (int i = 2; i <= k; ++i) { for (int j = 1; j <= cnt; ++j) { dp[i][j] = (dp[i][j-1] + (dp[i-1][cnt-j+1])*1LL*(r[j]-l[j]+1)%MOD)%MOD; } } printf("%d\n", dp[k][cnt]); return 0; }
AtCoder Beginner Contest 132 F Small Products
标签:href col Beginner c++ begin for http make names
原文地址:https://www.cnblogs.com/widsom/p/11110970.html