A 简单题
分析:没什么好说的,枚举精度就可以。。。
#include <bits/stdc++.h>
#define pi exp(1.0)
using namespace std;
typedef long long LL;
const int MAXN = 1e3 + 10;
int main() {
int n, a, c;
scanf("%d", &n);
while(n--) {
double b, ans = 1.0;
LL cnt = 1;
scanf("%d %lf %d", &a, &b, &c);
for(int i = 0; i < a; ++i) ans *= pi;
ans *= b;
if(c == 1) printf("%.1lf\n", ans);
if(c == 2) printf("%.2lf\n", ans);
if(c == 3) printf("%.3lf\n", ans);
if(c == 4) printf("%.4lf\n", ans);
if(c == 5) printf("%.5lf\n", ans);
}
return 0;
}
B
#include <bits/stdc++.h>
#define pi exp(1.0)
using namespace std;
typedef long long LL;
const int MAXN = 1e3 + 10;
int main() {
int n, c, b;
scanf("%d", &n);
while(n--) {
double a, ans = 1.0;
LL cnt = 1;
scanf("%lf %d %d", &a, &b, &c);
ans = pow(a, pi) / b;
if(c == 1) printf("%.1lf\n", ans);
if(c == 2) printf("%.2lf\n", ans);
if(c == 3) printf("%.3lf\n", ans);
if(c == 4) printf("%.4lf\n", ans);
if(c == 5) printf("%.5lf\n", ans);
}
return 0;
}
C
分析:推推公式或者找规律都行,考察快速幂。。。
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 1e3 + 10;
LL Q_mod(LL a, LL b, LL c) {
LL ans = 1;
while(b) {
if(b & 1) ans = (ans * (a % c)) % c;
a = ((a % c) * (a % c)) % c;
b >>= 1;
}
return ans % c;
}
int main() {
LL a, b, c, d, mod;
scanf("%lld %lld %lld %lld %lld", &a, &b, &c, &d, &mod);
if(a == 0 || b == 0) printf("0\n");
else {
LL ans1 = Q_mod(((a % mod) * (b % mod)) % mod, c * d, mod);
printf("%lld\n", ans1 % mod);
}
return 0;
}
D
分析:根据题目模拟
#include <bits/stdc++.h>
#define pi exp(1.0)
using namespace std;
typedef long long LL;
const int MAXN = 1e3 + 10;
int A[MAXN], B[MAXN], C[MAXN];
int main() {
int n, m;
scanf("%d %d", &n, &m);
for(int i = 0; i <= n; ++i) scanf("%d", &A[i]);
for(int i = 0; i <= m; ++i) scanf("%d", &B[i]);
for(int i = 0; i <= n; ++i) {
for(int j = 0; j <= m; ++j) {
C[i + j] += A[i] * B[j];
}
}
for(int i = 0; i <= n + m; ++i) {
if(i) printf(" ");
printf("%d", C[i]);
}
puts("");
return 0;
}
E
分析:正解把公式推一遍(我是瞎猜的)。。。
#include <bits/stdc++.h>
#define pi exp(1.0)
using namespace std;
typedef long long LL;
const int MAXN = 1e3 + 10;
int A[MAXN], B[MAXN], C[MAXN];
int main() {
double r;
scanf("%lf", &r);
printf("%.2lf\n", 1 + r);
return 0;
}
F
分析:把三维抽象成平面,注意每个平面的坐标轴。
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 10;
int visx[MAXN][MAXN], visy[MAXN][MAXN], visz[MAXN][MAXN];
int main() {
int n, x, y, z;
scanf("%d %d %d %d", &x, &y, &z, &n);
for(int i = 0; i < n; ++i) {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
visx[b][a] = 1;
visy[b][c] = 1;
visz[c][a] = 1;
}
for(int i = y; i >= 1 ; --i) {
for(int j = 1; j <= x; ++j) {
if(!visx[i][j]) printf(".");
else printf("x");
}
printf(" ");
for(int j = 1; j <= z; ++j) {
if(!visy[i][j]) printf(".");
else printf("x");
}
puts("");
}
printf("\n");
for(int i = 1; i <= z; ++i) {
for(int j = 1; j <= x; ++j) {
if(visz[i][j]) printf("x");
else printf(".");
}
printf("\n");
}
return 0;
}
G
建图+dp入门,这个图实在有点麻烦。。。
H
分析:A~G的音符推(猜)一遍?没什么可说的。
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 1e4 + 10;
char str[12][MAXN], ch[MAXN];
int main() {
int n, p = 0;
scanf("%d", &n);
for(int i = 0; i < 9; ++i) {
getchar();
scanf("%s", str[i]);
}
for(int i = 0; i < n; ++i) {
int cnt = -1;
for(int j = 0; j < 9; ++j) {
if(str[j][i] == 'o') {
cnt = j;
break;
}
}
if(cnt == 0 || cnt == 7) ch[p++] = 'F';
else if(cnt == 1 || cnt == 8) ch[p++] = 'E';
else if(cnt == 2) ch[p++] = 'D';
else if(cnt == 3) ch[p++] = 'C';
else if(cnt == 4) ch[p++] = 'B';
else if(cnt == 5) ch[p++] = 'A';
else if(cnt == 6) ch[p++] = 'G';
else if(str[0][i] == '|') ch[p++] = '|';
else ch[p++] = ' ';
}
for(int i = 0; i < n; ++i) {
printf("%c", ch[i]);
}
puts("");
return 0;
}
/*
8
--|o-|--
..|..|..
--|--|o-
..|..|..
-o|--|--
..|.o|..
--|--|-o
o.|..|..
--|--|--
*/
I
分析:
卡特兰数:1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796,,,要对这类数字及其演变的数字序列敏感起来。
另类递推式:h(n)=h(n-1)*(4*n-2)/(n+1);
递推关系的解为:h(n)=C(2n,n)/(n+1) (n=0,1,2,…)
递推关系的另类解为:h(n)=C(2n,n)-C(2n,n+1)(n=0,1,2,…)
本题为:ans = h(n) - h(n - 1);(费马小定理搞一下逆元)
卡特兰数详解
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 2e5 + 10;
const LL mod = 998244353;
LL dp[MAXN];
void init() {
dp[0] = 1;
for(LL i = 1; i < MAXN; ++i) {
dp[i] = (dp[i - 1] * i) % mod;
}
}
LL Q_mod(LL a, LL b) {
LL ans = 1;
while(b) {
if(b & 1) ans = (ans * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ans;
}
int main() {
int T, p = 1; init();
scanf("%d", &T);
while(T--) {
LL n;
scanf("%lld", &n);
LL ans1 = 1, ans2 = 1;
ans1 = ((ans1 * dp[n + n]) % mod * Q_mod(dp[n], mod - 2)) % mod;
ans1 = (ans1 * Q_mod(dp[n], mod - 2)) % mod;
ans1 = (ans1 * Q_mod(n + 1, mod - 2)) % mod;
n--;
ans2 = ((ans2 * dp[n + n]) % mod * Q_mod(dp[n], mod - 2)) % mod;
ans2 = (ans2 * Q_mod(dp[n], mod - 2)) % mod;
ans2 = (ans2 * Q_mod(n + 1, mod - 2)) % mod;
printf("Case #%d: %lld\n", p++, (ans1 - ans2 + mod) % mod);
}
return 0;
}
J
分析:map一下就行。
#include <bits/stdc++.h>
#define pi exp(1.0)
using namespace std;
typedef long long LL;
const int MAXN = 1e3 + 10;
map<string, string> ma;
map<string, int> mapp;
int main() {
int n; string s1, s2;
for(int i = 0; i < 3; ++i) {
cin>>s1>>s2;
ma[s2] = s1;
mapp[s1] = mapp[s2] = 1;
}
scanf("%d", &n);
while(n--) {
cin>>s1;
if(mapp[s1]) cout<<ma[s1]<<endl;
else puts("Fake");
}
return 0;
}