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. 根据ClassName获取元素节点

    功能描述: 通过ClassName获取元素节点,并解决兼容性问题 实现效果: 编码思路: 利用getElementsByTagName选出所有元素,再根据ClassName条件进行筛选 代码示例:

  2. jQuery 源码学习(先放在这,未开始)

    希望对源码有一个框架上认识,对整体结构有一个理解. 对外只暴露出了一个变量,$/jQuery,这个变量指向一个函数 function(a,b){return new n.fn.init(a,b)}

  3. NIC Bonding: 2 nic port as 1 interface

    The following is concluded from here. Consider we have 2 interfaces: eth0 & eth1 bond the two in ...

  4. selenium grid的使用与配置

    一.selenium grid的组成与作用:由一个集线器hub和多个客户机node组成,如果你的程序需要在不用的浏览器,不同的操作系统上测试,而且比较多的case需要多线程远程执行,那么一个比较好的测 ...

  5. flume-hdfs sinks报错

    flume使用hdfs sinks时候报错:org.apache.flume.EventDeliveryException: java.lang.NullPointerException: Expec ...

  6. openstack私有云布署实践【16.2 Ubuntu1404 只有根分区镜像制作】

    之所以要只有根分区镜像,是因为在创建VM或者调整云主机的硬盘大小时,它能自动扩容.无需人工介入   在原来的物理机10.40.41.1的CentOS 6.7上制作镜像. 宿主机坱要安装KVM相关软件: ...

  7. iframe、flash引入

    iframe引入 <iframe src="" width="" height="" frameborder="0" ...

  8. (负)-margin在页面布局中的应用

    有关margin的原理可以看看这篇文章:http://www.cnblogs.com/2050/archive/2012/08/13/2636467.html#2457812 有关margin负值的几 ...

  9. Linux中kettle启动spoon.sh遇到的问题

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAccAAAAYCAIAAAAAgaGrAAAE1klEQVR4nO1b2ZWrMAylLgpyPa7Gzb

  10. kettle 连接Hadoop

    http://wiki.pentaho.com/display/BAD/Additional+Configuration+for+YARN+Shims Copy *-site.xml Cluster ...