2025年河南工業大學2025新生周賽(2)
A 小唐的簽到
小唐到達教室的時間等于路上所用時間和上樓時間之和,注意如果教室在n樓,只需要上n-1層。
#include<bits/stdc++.h> using namespace std; int main() { int a, x, n, b, y; cin >> a >> x >> n >> b >> y; long long res = (x + a - 1) / a + (n - 1) * b; if (y >= res) cout << "qiandao"; else cout << "bu"; return 0; }
B 小唐的日歷
注意閏年
#include <bits/stdc++.h> #define int long long #define inf 1e18 #define maxn 400005 using namespace std; int const mod = 998244353; void solve() { int n, m; cin >> n >> m; int r = (n % 400 == 0) || (n % 4 == 0 && n % 100 != 0); // switch針對月份分支,直接輸出對應天數 switch (m) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: cout << 31; break; case 4: case 6: case 9: case 11: cout << 30; break; case 2: cout << (r ? 29 : 28); break; } return; } signed main() { ios::sync_with_stdio(false); cin.tie(0); // int t; cin >> t; // while (t--) solve(); return 0; }
C 小唐的密碼
n次循環錄入字符,并進行移動后依次輸出。
#include <bits/stdc++.h> using namespace std; signed main() { int n; cin >> n; char x; while (cin >> x) { int y = (x - 'a' + n) % 26; cout << (char)(y + 'a'); } return 0; }
D 小唐的運氣
(a-b)*t > x 時能追上。
#include <bits/stdc++.h> using namespace std; signed main() { int x, a, b, t; cin >> x >> a >> b >> t; if ((a - b) * t >= x) { cout << "yes" << endl; return 0; } else cout << "no" << endl; return 0; }
E 小唐的真名
循環遍歷,匹配字符。
#include <bits/stdc++.h> using namespace std; signed main() { int n; cin >> n; if (n < 7) { cout << "no\n"; return 0; } char t0 = 's', t1 = 'a', t2 = 'n', t3 = 'g', t4 = 'q', t5 = 'i', t6 = 'u'; int k = 0; char c; for (int i = 0; i < n; i++) { cin >> c; switch (k) { case 0:c == t0 && (k = 1); break; case 1:c == t1 ? k = 2 : (k = c == t0 ? 1 : 0); break; case 2:c == t2 ? k = 3 : (k = c == t0 ? 1 : 0); break; case 3:c == t3 ? k = 4 : (k = c == t0 ? 1 : 0); break; case 4:c == t4 ? k = 5 : (k = c == t0 ? 1 : 0); break; case 5:c == t5 ? k = 6 : (k = c == t0 ? 1 : 0); break; case 6:if (c == t6) { cout << "yes\n"; return 0; } else k = c == t0 ? 1 : 0; break; } }//會使用數組的話,可以減少大量碼量。 cout << "no\n"; return 0; }
F 小唐的工作
n天完成的任務量可以簡化為1-pow(0.5,n+1)。
#include <bits/stdc++.h> using namespace std; signed main() { int n; cin >> n; double x = pow(0.5, n); printf("%.18lf", 1-x); return 0; }
G 小唐的餅干
從第n天,每往前一天需要先加二再乘二,注意每中間數可能會很大,每一步運算都需要對114取模。
#include <bits/stdc++.h> using namespace std; int const mod = 114; signed main() { int n; cin >> n; n--; int re = 1; while (n--) re = ((re + 2) * 2) % mod; cout << re; return 0; }
H 小唐的升級
先計算獲得的經驗總和,在計算提升的等級。
#include <bits/stdc++.h> using namespace std; signed main() { int x, y, n; cin >> x >> y >> n; int m = y * n; int re = 0; while (m >= x) { m -= x; x *= 2; re++; } cout << re << endl; return 0; }

浙公網安備 33010602011771號