CSP-J 模拟赛 6
Done
ACM/ICPC
Start at: 2023-7-16 8:00
352
hour(s)
Host:
4
第一题代码:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5, inf = 0x3f3f3f3f, MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int A, B, C, D, id;
double ans;
while (cin >> A >> B >> C >> D)
{
ans = 0, id = 0;
// A B
// C D
if (ans < 1.0 * A / C + 1.0 * B / D)
{
ans = 1.0 * A / C + 1.0 * B / D;
id = 0;
}
// C A
// D B
if (ans < 1.0 * C / D + 1.0 * A / B)
{
ans = 1.0 * C / D + 1.0 * A / B;
id = 1;
}
// D C
// B A
if (ans < 1.0 * D / B + 1.0 * C / A)
{
ans = 1.0 * D / B + 1.0 * C / A;
id = 2;
}
// B D
// A C
if (ans < 1.0 * B / A + 1.0 * D / C)
{
ans = 1.0 * B / A + 1.0 * D / C;
id = 3;
}
printf("%d\n", id);
}
}
第二题代码: #include <stdio.h>
int n, t, f, ans;
char s[1005];
int check(int res = 1) {
if (s[0] < 'A' || s[0] > 'Z') res = 0;
for (int i = 1; s[i] != '\0'; i++)
if (s[i] < 'a' || s[i] > 'z') {
if (s[i + 1] == '\0' && (s[i] == '.' || s[i] == '!' || s[i] == '?'))
t++;
else
res = 0;
}
return res;
}
signed main() {
scanf("%d", &n);
do {
f = t;
scanf("%s", s);
ans += check();
if (t > f)
printf("%d\n", ans), ans = 0;
} while (t < n);
return 0;
}
第四题代码:#include <bits/stdc++.h>
using namespace std;
char a[1000007];
char b[100];
char stk[1000007];
int top;
int main() {
while (cin >> a >> b) {
top = 0;
int lb = strlen(b);
int lena = strlen(a);
for (int i = 0; a[i]; i++) {
stk[++top] = a[i];
while (top >= lb) {
bool flag = true;
for (int j = 0; j < lb; j++)
if (stk[top - lb + 1 + j] != b[j]) {
flag = false;
break;
}
if (flag) {
for (int j = 0; j < lb; j++) top--;
} else break;
}
}
if (top == 0) cout << "FRULA" << endl;
else {
for (int i = 1; i <= top; i++) cout << stk[i];
cout << endl;
}
}
return 0;
}
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 1
- Start at
- 2023-7-16 8:00
- End at
- 2023-7-31 0:00
- Duration
- 352 hour(s)
- Host
- Partic.
- 4