#JP15. 24KOI 2024 体验赛 No.01 标准程序

24KOI 2024 体验赛 No.01 标准程序

当前没有测试数据。

你要是直接复制那就没意思了

T1

#include <bits/stdc++.h>
using std::cin;
using std::cout;
int main()
{
    freopen("elevator.in", "r", stdin);
    freopen("elevator.out", "w", stdout);
    int n, s, p, lst = 0;
    cin >> n >> s >> p;
    for (int i = 1; i <= n; i++)
    {
        int t;
        cin >> t;
        if (t - lst > s)
        {
            long long ans = lst + s + p;
            cout << ans;
            return 0;
        }
        else
        {
            lst = t;
        }
    }
    cout << (long long)lst + s + p;
    return 0;
}

T2

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6;
int a[maxn];
int n;
signed main()
{
    freopen("problem.in","r",stdin);
    freopen("problem.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    if(n==2 ||a[1]==a[n])
    {
        cout<<"N";
        return 0;
    }
    for(int i=1;i<=n;i++)
    {
        if(i==2)
            cout<<"Z";
        else
            cout<<"Y";
    }
    return 0;
}

T3

#include <bits/stdc++.h>
using std::cin;
using std::cout;
int main()
{
    freopen("eat.in", "r", stdin);
    freopen("eat.out", "w", stdout);
    int a[4];
    a[1] = 1;
    a[2] = 2;
    int n;
    cin >> n;
    if (n == 0)
        cout << a[1];
    else if (n == 1)
        cout << a[2];
    else
    {
        n -= 1;
        while (n--)
        {
            a[3] = a[1] + a[2];
            a[3] %= 998244353;
            a[1] = a[2];
            a[2] = a[3];
        }
        cout << a[3];
    }
    return 0;
}

T4

#include <bits/stdc++.h>
using std::cin;
using std::cout;
int c, a[10010], b[10010], f[10010];
int F(int p)
{
    int s1 = 0;
    for (int j = 1; j <= p - 1; j++)
        if (p % j == 0)
            s1 += j;
    return s1;
}
int main()
{
    freopen("select.in","r",stdin);
    freopen("select.out","w",stdout);
    cin >> c;
    for (int i = 1; i <= c; i++)
        b[i] = F(i), a[i] = i;
    for (int i = 1; i <= c; i++)
    {
        for (int j = a[i]; j <= c; j++)
        {
            if (f[j] <= (f[j - a[i]] + b[i]))
                f[j] = f[j - a[i]] + b[i];
        }
    }
    cout << f[c]; 
}