Codeforces 682A Alyona and Numbers (water problem, mathematics)

Source: Internet
Author: User

Test instructions: Given two numbers m,n, ask you to add up to 5 in multiples from 1 to N, and 1 to M, and ask how many you have.

Analysis: First calculate how many modulo 5 in M and N is from 0 to 4, and then, according to the permutation combination, the multiplication is less than equal to M and N and can be divisible by five number, and then add the rest.

The code is as follows:

#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;}

Codeforces 682A Alyona and Numbers (water problem, mathematics)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.