CodeForces 678C Joty and Chocolate
简单题。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<stack>
using namespace std; long long n,a,b,p,q; long long gcd(long long a,long long b)
{
if(b==) return a;
return gcd(b,a%b);
} int main()
{
scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&p,&q); long long num1,num2,num3;
num1=n/a;
num2=n/b;
long long GCD=gcd(a,b);
long long LCM=a*b/GCD;
num3=n/LCM; long long ans=(num1-num3)*p+(num2-num3)*q+num3*max(p,q);
printf("%lld\n",ans); return ;
}
CodeForces 678C Joty and Chocolate的更多相关文章
- codeforces 678C. Joty and Chocolate(容斥) 2016-10-15 21:49 122人阅读 评论(0) 收藏
C. Joty and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standar ...
- codeforces 678C C. Joty and Chocolate(水题)
题目链接: C. Joty and Chocolate time limit per test 1 second memory limit per test 256 megabytes input s ...
- Educational Codeforces Round 13 C. Joty and Chocolate 水题
C. Joty and Chocolate 题目连接: http://www.codeforces.com/contest/678/problem/C Description Little Joty ...
- Educational Codeforces Round 1 E. Chocolate Bar 记忆化搜索
E. Chocolate Bar Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/prob ...
- Educational Codeforces Round 1 E. Chocolate Bar dp
题目链接:http://codeforces.com/contest/598/problem/E E. Chocolate Bar time limit per test 2 seconds memo ...
- Codeforces 689C. Mike and Chocolate Thieves 二分
C. Mike and Chocolate Thieves time limit per test:2 seconds memory limit per test:256 megabytes inpu ...
- codeforces 450C. Jzzhu and Chocolate 解题报告(449A)
题目链接:http://codeforces.com/contest/450/problem/C 题目意思:给出一个 n * m 大小的chocolate bar,你需要在这个bar上切 k 刀,使得 ...
- CodeForces 689C Mike and Chocolate Thieves (二分+数论)
Mike and Chocolate Thieves 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/G Description ...
- codeforces C. Jzzhu and Chocolate
http://codeforces.com/contest/450/problem/C 题意:一个n×m的矩形,然后可以通过横着切竖着切,求切完k次之后最小矩形面积的最大值. 思路:设k1为横着切的次 ...
随机推荐
- Xcode7修改模块生成网络权限(ATS配置)
直接找 前往->前往文件夹->然后复制下面的路径填入框内,回车就能看到想要替换的文件夹了 /Applications/Xcode.app/Contents/Developer/Pla ...
- kvstore之memcached为存储介质
ecstore中kvstore选用memcached作为存储介质 kvstore存储类选用base_kvstore_memcached(app/base/lib/kvstore/memcached.p ...
- 2015 ACM/ICPC Asia Regional Changchun Online
1001 Alisha’s Party 比赛的时候学长stl吃T.手写堆过. 赛后我贴了那两份代码都过.相差.2s. 于是用stl写水果. # include <iostream> # i ...
- Ansible 的委托 并发和任务超时
异步和轮询 Ansible 有时候要执行等待时间很长的操作, 这个操作可能要持续很长时间, 设置超过ssh的timeout. 这时候你可以在step中指定async 和 poll 来实现异步操作 a ...
- 域名、网站名、url的定义
网址:http://jingyan.baidu.com/article/2c8c281df0afd00008252aa7.html
- tomcat安装完设定用户名和密码
vi conf/tomcat-user.xml<tomcat-users> <role rolename="manager"/> <role role ...
- 浅谈C/C++引用和指针的联系和区别
为什么C/C++语言使用指针? 答案:①一方面,每一种编程语言都使用指针.不止C/C++使用指针. 每一种编程语言都使用指针.C++将指针暴露给了用户(程序员),而Java和C#等语言则将指针隐藏起来 ...
- POJ1613 147/思维题
题目链接[https://www.oj.swust.edu.cn/problem/show/1613] 题意:输出第K小的由1.4.7数字组成的数字. 解题过程:1.4.7.11.14.17.41.4 ...
- sql 将表B中不存在表A的数据 插入到表A中
insert into tableA select * from tableB b where not exists(select 1 from tableA a where a.id = b.id) ...
- HDU 4585 Shaolin (set的应用)
set是STL中非常方便的工具,可以实现自动去重和排序,可我一直忽视它的重要性,导致吃了好几次亏. 在思考这道题的时候,我一直往二分上靠拢,可是二分需要直接插入排序,直接插入排序覆盖的时候复杂度最大是 ...