zoukankan      html  css  js  c++  java
  • CodeForces 682A Alyona and Numbers (水题,数学)

    题意:给定两个数 m,n,问你在从1到 n,和从 1到 m中任选两个数加起来是5的倍数,问你有多少个。

    析:先计算 m 和 n中有多少个取模5是从0到4的,然后根据排列组合,相乘就得到了小于等于 m 和 n的并且能整除五的个数,然后再加上剩下的。

    代码如下:

    #include <bits/stdc++.h>
    
    using namespace std;
    typedef long long LL;
    const int aa = 1234567;
    const int bb = 123456;
    const int cc = 1234;
    
    int main(){
        int n, m;
        while(cin >> n >> m){
            int x = n / 5, y = m / 5;
            int xx = n % 5, yy = m % 5;
            LL ans = (LL)x * (LL)y * 5;
            ans += xx * y + yy * x;
            if(xx + yy >= 5)  ans += (xx + yy) / 5 + (xx + yy) % 5;
            cout << ans << endl;
        }
        return 0;
    }
    
  • 相关阅读:
    第二次作业
    第四次作业
    第三次作业
    第二次作业
    第一次作业
    第四次作业
    第三次作业
    第二次作业
    第一次大学作业
    第四次作业
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/5655857.html
Copyright © 2011-2022 走看看