题意:给定两个数 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;
}

CodeForces 682A Alyona and Numbers (水题,数学)的更多相关文章

  1. CodeForces 682A Alyona and Numbers (水题)

    Alyona and Numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/A Description After fi ...

  2. Codeforces Round #358 (Div. 2) A. Alyona and Numbers 水题

    A. Alyona and Numbers 题目连接: http://www.codeforces.com/contest/682/problem/A Description After finish ...

  3. VK Cup 2016 - Qualification Round 2 A. Home Numbers 水题

    A. Home Numbers 题目连接: http://www.codeforces.com/contest/638/problem/A Description The main street of ...

  4. codeforces 577B B. Modulo Sum(水题)

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

  6. codeforces 659A A. Round House(水题)

    题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...

  7. Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  8. codeforces 696A Lorenzo Von Matterhorn 水题

    这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...

  9. CodeForces 589I Lottery (暴力,水题)

    题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...

随机推荐

  1. 【游记】noip2017酱油记

    2017-10-14:初赛 12:00:比赛时间14:30-16:30,由于比赛地点在二附中,我12点就坐上了地铁(无力吐槽,周六中午人还那么多,站了一路). 13:45:到了efz,所有人都被拦在了 ...

  2. java死锁及解决方案

    死锁是两个甚至多个线程被永久阻塞时的一种运行局面,这种局面的生成伴随着至少两个线程和两个或者多个资源.避免死锁方针:a:避免嵌套封锁:这是死锁最主要的原因的,如果你已经有一个资源了就要避免封锁另一个资 ...

  3. SET STATISTICS IO

    SET STATISTICS IO (Transact-SQL) https://technet.microsoft.com/zh-cn/library/ms184361(SQL.90).aspx 如 ...

  4. SQLServer数据库优化常用语句

    -- 平均物理读次数最多的SQL语句:select top 50 *, (s.total_physical_reads / s.execution_count) as avephysicalreads ...

  5. poj 3518 Prime Gap

    Prime Gap Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7392   Accepted: 4291 Descrip ...

  6. [CSAPP] Chapter 1 Overview of Computer

    1.1 information is bits + context All computer programs are just a sequence of bits, each with a val ...

  7. github上的版本发布

    当前的版本号 发布版本 比如 git tag -a v1. 把这个版本发布到线上 git push --tags

  8. FTP服务器(SOCKET)返回异常 500 Command not understood

    出现着这样的问题,一般是NLST中的参数包含特殊字符,如"\n",所以在发送SOCKET命令时,一定要检查命令参数的合法性.

  9. 在Spring中使用Redis Lua脚本批量删除缓存

    背景 之前分享了一篇利用lua脚本批量删除redis的key的文章.现在项目中我打算使用spring的缓存,而Spring缓存以前我是用ehcache来做实现的.没发现什么问题..这次我换成redis ...

  10. JSTL中EL表达式无法直接取size的处理

    jsp中使用${list.size }会编译成list.getSize()方法,并不能获取list的长度,因为程序回去找List对象中的getSize()方法,所以只能想别的办法, 一种方法是在后台程 ...