CSP-J 模拟赛 6
已结束
ACM/ICPC
开始于: 2023-7-16 8:00
352
小时
主持人:
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; }
- 状态
- 已结束
- 规则
- ACM/ICPC
- 题目
- 1
- 开始于
- 2023-7-16 8:00
- 结束于
- 2023-7-31 0:00
- 持续时间
- 352 小时
- 主持人
- 参赛人数
- 4