4 条题解

  • 1
    @ 2023-4-29 13:09:37

    由于 n<=106n<=10^6 直接模拟即可。

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
        int x, n, a = 0;
        cin >> x >> n;
        while(n--) {               // 经过 n 天
            if(x == 8) x = 1;      // 到星期八时设为星期一
            if(x != 6 && x != 7) { // 周末休息(实行双休日)
                a += 250;          // 平日每天游泳 250 公里
            }
            ++x;                   // 后一天
        }
        cout << a;                 // 输出一个整数,表示小鱼累计游泳了多少公里
        return 0;
    }
    

    循环不使用,难理解一些但是 O(1)O(1)

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
        int x, n, a = 0;
        cin >> x >> n;
        int r = n % 7;
        if(r != 0) {
            if(x == 7 || r + x == 7) --r;  // 如果开始日为周日或结束日为周日都要休息一天
            else if(r + x >= 8) r -= 2;    // 周一到周六需要休息两天
        }
        cout << ((n / 7 * 5) + r) * 250 << endl;
        return 0;
    }
    
    • 0
      @ 2022-6-5 10:12:31
      #include<bits/stdc++.h>
      using namespace std;
      int a,b,s;
      int i;
      int main()
      {
          cin>>a>>b;
          for(i=a;i<=b+a-1;i++)
          {
              if(i%7!=6&&i%7!=0)
              s+=250;
          }
          cout<<s;
          ///printf("%0.4f",s);
          return 0;
      }
      
      • 0
        @ 2022-5-18 22:09:02

        `

        #include <bits/stdc++.h>
        using namespace std;
        int main(){
            int x, n;
            cin >> x >> n;
            cout << (n - (int(n / 7.0+0.5) * 2 + ((n % 7 != 0) ? ((x - 6 >= 0) ? 1 : 0) : 0))) * 250 << endl;
            return 0;
        }
        
        • 0
          @ 2021-10-10 8:51:40

          #include<cstdio> int main(){ int n=0,f,l; scanf("%d%d",&f,&l); for(int i=f;i<l+f;i++) if(i%7>0&&i%7<6) n=n+250; printf("%d",n); return 0; }

          • 1

          信息

          ID
          424
          时间
          1000ms
          内存
          125MiB
          难度
          1
          标签
          (无)
          递交数
          254
          已通过
          118
          上传者