Cake

Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 32   Accepted Submission(s) : 14
Problem Description
一次生日Party可能有p人或者q人参加,现准备有一个大蛋糕.问最少要将蛋糕切成多少块(每块大小不一定相等),才能使p人或者q人出席的任何一种情况,都能平均将蛋糕分食.
 
Input
每行有两个数p和q.
 
Output
输出最少要将蛋糕切成多少块.
 
Sample Input
2 3
 
Sample Output
4 [hint]将蛋糕切成大小分别为1/3,1/3,1/6,1/6的四块即满足要求. 当2个人来时,每人可以吃1/3+1/6=1/2 , 1/2块。 当3个人来时,每人可以吃1/6+1/6=1/3 , 1/3, 1/3块。[/hint]
 
Author
LL
 
Source
HZIEE 2007 Programming Contest

 #include <stdio.h>
#include <stdlib.h> int fun(int MAX,int MIN)
{
int sign;
do
{
sign=MAX%MIN;
MAX=MIN;
MIN=sign;
}while(MIN!=);
return (MAX);
} int main()
{
int MAX,MIN,a,b,sum;
while(scanf("%d%d",&a,&b)!=EOF)
{
MAX=(a>b)?a:b;
MIN=a+b-MAX;
sum=MAX+MIN-fun(MAX,MIN);
printf("%d\n",sum);
}
return ;
}

Cake的更多相关文章

  1. Windows 7上执行Cake 报错原因是Powershell 版本问题

    在Windows 7 SP1 电脑上执行Cake的的例子 http://cakebuild.net/docs/tutorials/getting-started ,运行./Build.ps1 报下面的 ...

  2. 2015暑假多校联合---Cake(深搜)

    题目链接:HDU 5355 http://acm.split.hdu.edu.cn/showproblem.php?pid=5355 Problem Description There are m s ...

  3. Scalaz(15)- Monad:依赖注入-Reader besides Cake

    我们可以用Monad Reader来实现依赖注入(dependency injection DI or IOC)功能.Scala界中比较常用的不附加任何Framework的依赖注入方式可以说是Cake ...

  4. uva10167 Birthday Cake

    Lucy and Lily are twins. Today is their birthday. Mother buys a birthday cake for them. Now we put t ...

  5. HDU 4762 Cut the Cake(公式)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  6. Brute Force --- UVA 10167: Birthday Cake

     Problem G. Birthday Cake  Problem's Link:http://uva.onlinejudge.org/index.php?option=com_onlinejudg ...

  7. 2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest, B. Layer Cake

    Description Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping ...

  8. hdu acmsteps 2.1.3 Cake

    Cake Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submissi ...

  9. ZOJ 3905 Cake ZOJ Monthly, October 2015 - C

    Cake Time Limit: 4 Seconds      Memory Limit: 65536 KB Alice and Bob like eating cake very much. One ...

  10. HDU 5640 King's Cake

    King's Cake Problem Description It is the king's birthday before the military parade . The ministers ...

随机推荐

  1. Android中的eventBus传值

    第一步:在build.gradle中添加依赖dependencies { compile 'org.greenrobot:eventbus:3.0.0'} 第二步:创建一个 Event类: 注意:en ...

  2. PHP来实现文件上传

    文件php <?phpif ($_FILES["file"]["error"] > 0){ echo '错误: ' . $_FILES[" ...

  3. sybase 修改用户密码

    命令行输入 isql -Usa -P123456 将sa口令设置为NULL(当前口令为"123456"):  sp_password '123456',NULL,sa

  4. 【转】spring管理属性配置文件properties——使用PropertiesFactoryBean|spring管理属性配置文件properties——使用PropertyPlaceholderConfigurer

     spring管理属性配置文件properties--使用PropertiesFactoryBean 对于属性配置,一般采用的是键值对的形式,如:key=value属性配置文件一般使用的是XXX.pr ...

  5. openstack私有云布署实践【12.1 网络Neutron-controller节点配置(科兴环境)】

    网络这一块推荐使用的是 Neutron--LinuxBirdge的Ha高可用,此高可用方案对Public作用不是很大,Public只用到DHCP,而Private则会用到L3 Agent,则此方案是有 ...

  6. openstack私有云布署实践【4.1 上层代理haproxy配置 (科兴环境)】

    官方文档上的高可用配置,它推荐的是使用haproxy的上层代理来实现服务组件的主备访问.或者负载均衡访问   一开始我也是使用haproxy来做的,但后来方式改了   测试环境:haproxy + n ...

  7. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver问题

    java.lang.ClassNotFoundException: com.mysql.jdbc.Driverat org.apache.catalina.loader.WebappClassLoad ...

  8. Java 泛型 泛型方法

    Java 泛型 泛型方法 @author ixenos 泛型方法可以定义在普通类中,也可以定义在泛型类中 类型变量放在修饰符(如public static)后面,返回类型的前面 一个static方法无 ...

  9. Webpack入门——使用Webpack打包Angular项目的一个例子

    2016.1.22,对大多数人来说,这是一个非常平常的日子,但这却是我决定在博客园写博客的日子.虽然注册博客园的博客已有4年8个月,却一直没有动手写过一篇博客,原因是觉得自己水平不行,写不出好东西,所 ...

  10. Infix to postfix without '(' and ')'

    #include<iostream> #include<stack> #include<string> #include<deque> using na ...