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为横着切的次 ...
随机推荐
- OC 截取字符串
1.定义一个字符串a, 截取a 的某一个部分,复制给b, b必须是int型 NSString *a = @"1.2.30"; int b= [[a substringWithRa ...
- js中两个感叹号的原理与用法分析(转载记录没找到原帖)
var foo; alert(!foo);//undifined情况下,一个感叹号返回的是true; alert(!goo);//null情况下,一个感叹号返回的也是true; var o={flag ...
- 5.编写Java应用程序。首先,定义描述学生的类——Student,包括学号(int)、 姓名(String)、年龄(int)等属性;二个方法:Student(int stuNo,String name,int age) 用于对对象的初始化,outPut()用于输出学生信息。其次,再定义一个主类—— TestClass,在主类的main方法中创建多个Student类的对象,使用这些对象来测 试St
Student类: package com.bao; public class Student { int stuNo;String name,sex;int age,weight; Student( ...
- ClassLoader类加载解惑
1.通过类加载器获取路径: String path = Thread.currentThread().getContextClassLoader().getResource("." ...
- WEB组件 开发 (未完成 4-13)
整理自真阿当的阿当大话西游之WEB组件,课件中的代码下载. 14. 抽出widget类 组件分两大类: utility(大部分与UI无关的组件) 和 widget(应用层,大部分与UI相关的,日历组件 ...
- A. Launch of Collider Codeforces Round #363 (Div2)
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- HDU 3416 Marriage Match IV
最短路+最大流 #include<cstdio> #include<cstring> #include<string> #include<cmath> ...
- 几个可用于数据挖掘和统计分析的java库
http://itindex.net/blog/2015/01/09/1420751820000.html WEKA:WEKA是一个可用于数据挖掘任务的机器学习算法集合.该算法可以直接应用到数据集或从 ...
- Shiro 的FilterChain
/** * Shiro的FilterChain * @see ===================================================================== ...
- Eclipse中配置weka,以及添加算法
Eclipse中配置weka 1 找到weka的安装位置,寻找weka的压缩文件weka-src.jar,将压缩文件解压,解压出的文件夹weka-src. 2 打开Eclipse,新建Java pro ...