Codeforces 678C Joty and Chocolate
来源:互联网 发布:ubuntu 17.04更新源 编辑:程序博客网 时间:2024/04/30 10:02
题目大意:有下标为1到n的n个瓷砖,如果某个瓷砖下标能被a整除,那么就能获得p块巧克力,如果能被b整除,就能获得q块巧克力,如果同时被a和b整除,就随便你要哪种巧克力
如果能同时被a和b整除,肯定选最多的那一个啊
#include<iostream>using namespace std;typedef long long ll;ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}ll lcm(ll a,ll b){return a/gcd(a,b)*b;}int main(){ll n,a,b,p,q;while(cin>>n>>a>>b>>p>>q){cout<<n/a*p+n/b*q-min(p,q)*(n/lcm(a,b))<<endl;}}
阅读全文
0 0
- Codeforces 678 C. Joty and Chocolate
- Codeforces-678C-Joty and Chocolate
- codeforces 678C Joty and Chocolate
- Codeforces 678C Joty and Chocolate
- codeforces 678C. Joty and Chocolate(容斥)
- codeforces-678-C. Joty and Chocolate(数学)
- Educational Codeforces Round 13 C Joty and Chocolate(数学)
- D - Joty and Chocolate
- Joty and Chocolate
- Joty and Chocolate
- Codeforces 678C Mike and Chocolate Thieves(二分)
- codeforces 6C - Alice, Bob and Chocolate
- Codeforces 450 C. Jzzhu and Chocolate
- Codeforces 450 C. Jzzhu and Chocolate
- codeforces #257 C题Jzzhu and Chocolate
- Codeforces Round #257 C.Jzzhu and Chocolate
- Codeforces 6C. Alice, Bob and Chocolate
- CodeForces 6C - Alice, Bob and Chocolate
- HDOJ 2020 绝对值排序
- 如何用keil和proteus点亮流水灯
- javaScript常用总结
- vue在window安装教程
- iOS图片逐渐加载的效果实现
- Codeforces 678C Joty and Chocolate
- Java序谈之泛型知识点
- 46-IO流(Properties集合的-练习)12 47-IO流(综合练习-文件清单列表. 48-IO流(打印流-PrintStream) 49-IO流(打印流-PrintWriter).
- 欧拉回路学习
- 使用Dynamsoft Twain实现Web 在线扫描上传
- J2EE与中间件 学习笔记1 JDBC Session Servlet
- 分治---快速排序
- 第四章 键值对操作(一)
- unity粒子系统碰撞