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;
}
CodeForces 682A Alyona and Numbers (水题,数学)的更多相关文章
- CodeForces 682A Alyona and Numbers (水题)
Alyona and Numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/A Description After fi ...
- Codeforces Round #358 (Div. 2) A. Alyona and Numbers 水题
A. Alyona and Numbers 题目连接: http://www.codeforces.com/contest/682/problem/A Description After finish ...
- 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 ...
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
- codeforces 659A A. Round House(水题)
题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
- CodeForces 589I Lottery (暴力,水题)
题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...
随机推荐
- Jquery获取用户控件页面中控件的值
$('#<%= txt_P_name.ClientID%>').val()
- ThinkPHP 配置详解
3.0 ThinkPHP配置详解 3.1 入口文件的配置 一般不建议在入口文件做过多的配置,但可以重新定义一些系统常量,以下简单介绍几个常用的系统常量. 1.APP_PATH 默认情况下,框架的项 ...
- SQL Server此数据库没有有效所有者
一般此问题出现在还原外部数据库文件的时候,是因为还原的时候本机数据库没有所还原数据库中的用户. 1.选中所还原数据库,安全->用户,删除没有的用户. 2.选中所还原数据库,右键属性->文件 ...
- canvas下载图片
canvas下载图片 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- Centos7 / RHEL 7 双网卡绑定
http://www.cnblogs.com/hukey/p/6224969.html 1. 简要 双网卡绑定技术在centos7中使用了teaming技术,而在rhel6/centos7中使用 ...
- 仿知乎日报App
1.6.Error:Execution failed for task ':app:buildInfoDebugLoader'.> Exception while doing past iter ...
- GameObject.DestroyImmediate(go, true)会使磁盘资源数据丢失,导致不可用
GameObject.DestroyImmediate(go, true)会使磁盘资源数据丢失,导致不可用 第二个参数true表示 allowDestroyingAssets,表示允许销毁资源. 实测 ...
- UNITY 模型与动画优化选项
1,RIG: Optimze Game Objects,[默认是没勾选的] 效果:将骨骼层级从模型中移除,放到动画控制器中,这样性能提高明显.实测中发现原来瞬间加载5个场景角色有点延迟,采用此选项后流 ...
- ROS 禁止公网暴力破解SSH FTP
最简单的彻底禁止公网访问SSH FTP端口 1 2 /ip firewall filter add chain=input protocol=tcp dst-port=21-22 src-addres ...
- docker plugin test
docker build -t docker-volume-drbd . id=$(docker create docker-volume-drbd true) docker export $id - ...