AcWing 4402. 刷题统计

题目

小明决定从下周一开始努力刷题准备蓝桥杯竞赛。

他计划周一至周五每天做 \(a\) 道题目,周六和周日每天做 \(b\) 道题目。

请你帮小明计算,按照计划他将在第几天实现做题数大于等于 \(n\) 题?

输入格式

输入一行包含三个整数 \(a, b\)\(n\)

输出格式

输出一个整数代表天数。

数据范围

对于 \(50\%\) 的评测用例,\(1 ≤ a, b, n ≤ 10^6\)
对于 \(100\%\) 的评测用例,\(1 ≤ a, b, n ≤ 10^{18}\)

输入样例:

10 20 99

输出样例:

8

题解

感觉写的比较复杂 但时间复杂度还行 注意要开成long long
第一次WA就是因为输出时没有开成%lld 所以用printf就一定要注意
本题实际上就考了个数学思维

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

LL a, b, n;

int main()
{
    scanf("%lld%lld%lld", &a, &b, &n);
    LL pos = 5 * a + 2 * b;
    LL res = (n / pos) * 7;
    if (n % pos != 0)
    {
        LL ty = n % pos;
        if (ty <= 5 * a)
        {
            if (ty % a != 0) res += ty / a + 1;
            else res += ty / a;
        }
        else
        {
            ty -= 5 * a;
            if (ty % b != 0) res += ty / b + 1 + 5;
            else res += ty / b + 5;
        }
    }

    printf("%lld\n", res);

    return 0;
}
posted @ 2024-04-16 17:03  MsEEi  阅读(7)  评论(0)    收藏  举报