总结
期望得分:\(50 + 100 + 0 = 150\)
实际得分:\(20 + 70 + 0 = 90\)
\(T1\)找到了\(50\)分的规律,然而模数取错了,\(T2\)找出了正解,但是数组开小了,\(T3\)不会
思路&&代码
T1
找规律
#include
#include
#include
using namespace std;
const int mod=1e9+7;
inline int read() {
int x=0,f=0;
char ch=getchar();
while(!isdigit(ch))f|=ch=='-',ch=getchar();
while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
return f?-x:x;
}
inline int Fast_pow(int b,int p,int ans=1) {
while(p) {
if(p&1)ans=1ll*ans*b%mod;
b=1ll*b*b%mod;
p>>=1;
}
return ans;
}
int main() {
int n=read()-1,k=read(),ans,nn=1ll*n*n%mod;
int a=1ll*(Fast_pow(nn,k/2)-1+mod)%mod*Fast_pow(nn-1,mod-2)%mod;
int b=1ll*n*(Fast_pow(nn,(k-1)/2)-1+mod)%mod*Fast_pow(nn-1,mod-2)%mod;
if(k&1)ans=(b-a+mod)%mod;
else ans=(a-b+mod)%mod;
printf("%d\n",1ll*ans*Fast_pow(Fast_pow(n,k-1),mod-2)%mod);
return 0;
}
T2
k等于1
#include
#include
#include
#include
#include
#define FOR(i, x, y) for(int i = x; i <= y; i++)
#define QWQ(i, x, y) for(int i = x; i >= y; i--)
using namespace std;
const int A = 1e3 + 11;
const int B = 1e6 + 11;
const int inf = 0x3f3f3f3f;
inline int read() {
char c = getchar();
int x = 0, f = 1;
for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1;
for( ; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
return x * f;
}
struct node {
int w, v;
} box[A];
int a, b, m, K, cnt;
int f[301][301][51];
int main() {
freopen("b.in", "r", stdin);
freopen("b.out", "w", stdout);
a = read(), b = read(), m = read(), K = read();
if(a == 0 && b == 0) return puts("0"), 0;
if(m == 0) return puts("Impossible"), 0;
for(int i = 1; i <= m; i++) box[i].w = read(), box[i].v = read(), cnt += box[i].w;
if(cnt < a + b) return puts("Impossible");
memset(f, inf, sizeof(f));
if(m <= 50 && a <= 50 && b <= 50);
else K = min(1, K);
f[0][0][0] = 0;
FOR(i, 1, m) QWQ(j, a, 0) QWQ(k, b, 0) QWQ(w, K, 0) {
if(box[i].w >= 2 && j && k && w) f[j][k][w] = min(f[j - 1][k - 1][w - 1] + box[i].v, f[j][k][w]);
f[j][k][w] = min(f[j][k][w], f[max(0, j - box[i].w)][k][w] + box[i].v);
f[j][k][w] = min(f[j][k][w], f[j][max(0, k - box[i].w)][w] + box[i].v);
}
int ans = inf;
for(int k = 0; k <= K; k++) ans = min(ans, f[a][b][k]);
cout << ans << '\n';
return 0;
}
T3
不会