Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
119032 陈家宝 数学,很美妙吧 C++ 通过 100 234 MS 160576 KB 1003 2024-01-03 13:35:01

Tests(10/10):


#include<bits/stdc++.h> using namespace std; inline int read(){ register int x(0); register short w(1); register char c(getchar()); for(;c < '0' || c > '9';c = getchar()) if(c == '-')w = -1; for(;c >= '0' && c <= '9';c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); return x * w; } const int N(5010),Mod(1e9 + 7); int n,m,k; long long ans,s[N][N]; long long qp(long long a,int b){ long long ans(1); while(b){ if(b & 1)ans = ans * a % Mod; a = a * a % Mod; b >>= 1; } return ans; } int main(){ n = read(),k = read(),m = read();s[0][0] = 1; for(int i(1);i <= n;i++){ for(int j(1);j <= i;j++) s[i][j] = (s[i - 1][j - 1] + s[i - j][j]) % Mod; } // for(int i(1);i <= n;i++){ // for(int j(1);j <= n;j++) // cout << s[i][j] << " "; // cout << endl; // } for(int i(1);i <= n;i++){ int cur(qp(i,m)); for(int j(1);j <= k && n - i * j >= k - j;j++) ans = (ans + cur * 1ll * s[n - i * j][k - j]) % Mod; } cout<<ans; return 0; }


测评信息: