2 条题解

  • 1
    @ 2024-3-20 0:10:44

    【2022省赛B组】试题C:刷题统计

    题解

    🎉️ 一周的做题量为5×a+2×b5 \times a + 2 \times b, 这是一个固定的值。需要实现大于等于nn题,可以先计算至少需要多少周。

    🎉️ 直接用nn除以5×a+2×b5 \times a + 2 \times b得到需要花费的周数,剩下的题数为nn, 直接暴力计算需要几天可以完成。

    提交代码

    #include<bits/stdc++.h>
    #define int long long
    
    void solve()
    {
        int a, b, n;
        std::cin >> a >> b >> n;
        int cycle = a * 5 + b * 2;
        int ans = (n / cycle) * 7;
        int rest = n % cycle;
        if(rest <= a * 5)
        {
            ans += (rest + a - 1) / a;
        }
        else
        {
            ans += 5;
            rest -= a * 5;
            ans += (rest + b - 1) / b;
        }
        std::cout << ans << "\n";
    }
    signed main()
    {
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        int t = 1; 
        while(t--) solve();
        return 0;
    }
    
    • 0
      @ 2024-4-8 22:52:23
      n=int(input("请输入n:"))
      day=0
      ti=0
      a=int(input("请输入a:"))
      b=int(input("请输入b:"))
      for i in range(n):
          day+=1
          if day%7<=5 and day%7>0:
              ti+=a
          elif day%7==0 or day%7==6:
              ti+=b
          if ti>=n:
              print(day)
              break
      
      • 1

      信息

      ID
      968
      时间
      1000ms
      内存
      256MiB
      难度
      3
      标签
      递交数
      289
      已通过
      53
      上传者