8.14
作者:互联网
做题做题做题
PS:时间紧,码风没时间调
生成树
代码:
#include <bits/stdc++.h>
#define int long long
#define debug
using namespace std;
//东方之珠 整夜未眠!
const int mod = 2007;
inline int ksm(int a, int b) {
int res = 1;
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res%mod;
}
inline int work(int x){
return 4 * x * ksm(5, x - 1)%mod;
}
inline int thestars() {
int x, T;
cin >> T;
while (T --) {
cin >> x;
cout << work(x) << '\n';
}
return 0;
}
int youngore = thestars();
signed main() {;}
硬币购物
#include <bits/stdc++.h>
#define N 100001
using namespace std;
//男儿有胆气 仗剑走天涯
int i, j, T, sum;
long long res, dp[N+10], t;
int c[5], d[5];
int main () {
for (i = 1; i <= 4; ++ i) cin >> c[i];
dp[0] = 1;
for (i = 1; i <= 4; ++ i)
for (j = c[i]; j <= N; ++ j)
dp[j] += dp[j-c[i]];
cin >> T;
while (T --> 0) {
res = 0;
for (i = 1; i <= 4; ++ i) cin >> d[i];
cin >> sum;
for (i = 0; i <= 15; ++ i) {
t = sum;
int cnt(0);
for (j = 1; j <= 4; ++ j) if ((i>>(j-1))&1) t -= c[j]*(d[j]+1), cnt^=1;
if (t<0) continue;
if (!cnt) res += dp[t];
else res -= dp[t];
}
cout << res << '\n';
}
return 0;
}
玉蟾宫
#include <bits/stdc++.h>
#define LL long long
#define debug
using namespace std;
//东方之珠 整夜未眠!
const int N = 1e3+10;
int a[N][N], sta[N], lp[N], rp[N];
char str[5];
inline int thestars() {
int i, j, n, m, res(0), dadada(0);
scanf ("%d%d", &n, &m);
for (i = 1; i <= n; ++ i) {
for (j = 1; j <= m; ++ j) {
scanf ("%s", str);
if (str[0] == 'F') {
a[i][j] = a[i - 1][j] + 1;
}
}
res = 0, sta[0] = 0;
for (j = 1; j <= m; ++ j) {
while (res && a[i][j] <= a[i][sta[res]]) -- res;
lp[j] = sta[res], sta[++ res] = j;
}
res = 0, sta[res] = m + 1;
for (j = m; j; -- j) {
while (res && a[i][j] <= a[i][sta[res]]) -- res;
rp[j] = sta[res], sta[++ res] = j;
}
for (j = 1; j <= m; ++ j) {
dadada = max(dadada, a[i][j]*(rp[j] - lp[j] - 1));
}
}
cout << dadada*3;
return 0;
}
int youngore = thestars();
signed main() {;}
标签:int,res,long,inline,8.14,define,mod 来源: https://www.cnblogs.com/yszhyhm/p/13509884.html