Codeforces-682A:Alyona and Numbers(水题)
来源:互联网 发布:靠谱韩国代购淘宝店 编辑:程序博客网 时间:2024/05/22 03:25
After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers — the first column containing integers from 1 to n and the second containing integers from 1 to m. Now the girl wants to count how many pairs of integers she can choose, one from the first column and the other from the second column, such that their sum is divisible by 5.
Formally, Alyona wants to count the number of pairs of integers (x, y) such that 1 ≤ x ≤ n, 1 ≤ y ≤ m and equals 0.
As usual, Alyona has some troubles and asks you to help.
The only line of the input contains two integers n and m (1 ≤ n, m ≤ 1 000 000).
Print the only integer — the number of pairs of integers (x, y) such that 1 ≤ x ≤ n, 1 ≤ y ≤ m and (x + y) is divisible by 5.
6 12
14
11 14
31
1 5
1
3 8
5
5 7
7
21 21
88
Following pairs are suitable in the first sample case:
- for x = 1 fits y equal to 4 or 9;
- for x = 2 fits y equal to 3 or 8;
- for x = 3 fits y equal to 2, 7 or 12;
- for x = 4 fits y equal to 1, 6 or 11;
- for x = 5 fits y equal to 5 or 10;
- for x = 6 fits y equal to 4 or 9.
Only the pair (1, 4) is suitable in the third sample case.
#include<bits/stdc++.h>using namespace std;__int64 sum[5];int main(){ memset(sum,0,sizeof sum); int n,m; __int64 ans=0; scanf("%d%d",&n,&m); for(int i=1;i<=m;i++)sum[i%5]++; for(int i=1;i<=n;i++)ans+=sum[(5-i%5)%5]; cout<<ans<<endl; return 0;}
- Codeforces-682A:Alyona and Numbers(水题)
- CodeForces 682A Alyona and Numbers
- CodeForces 682A Alyona and Numbers
- codeforces 682 a 解题报告 Alyona and Numbers 数论基础
- CodeForces 682A Alyona and Numbers(被整除的个数)
- Codeforces Round #358 (Div. 2) A Alyona and Numbers(水题)
- A. Alyona and Numbers
- Codeforces Round #358 (Div. 2) A. Alyona and Numbers
- Codeforces Round #358 (Div. 2) A. Alyona and Numbers
- Codeforces Round #358 (Div. 2) A. Alyona and Numbers
- Codeforces Round #358 (Div. 2) A. Alyona and Numbers
- Codeforces Round #358 (Div. 2)(A) Alyona and Numbers
- codeforce A. Alyona and Numbers
- Codeforces Round #358 (Div. 2) -- A. Alyona and Numbers(暴力水题)
- Codeforces 739A Alyona and mex(构造)
- 【20.23%】【codeforces 740A】Alyona and copybooks
- Codeforces 740A Alyona and copybooks
- CodeForces 740A Alyona and copybooks
- 欢迎使用CSDN-markdown编辑器
- STL模拟实现1.0 -- list和iterator模拟实现和简单分析
- 第一周LeetCode
- hdu1533(费用流模板)
- 贪心算法
- Codeforces-682A:Alyona and Numbers(水题)
- 调用百度地图API确定地址的经纬度,根据地址的经纬度查找中文地址
- TableLayout与ViewPager联动
- 【算法导论33】跳跃表(Skip list)原理与java实现
- QT之使用QMutex/ QMutexLocker互斥量同步线程小例子
- Asp.net MVC3 自定义HtmlHelper控件
- The SetStack Computer UVA
- 继承
- CentOS7 安装Chrome浏览器