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;
}

 

posted @ 2025-11-04 22:05  河南工业大学算法协会  阅读(156)  评论(0)    收藏  举报