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. GitHub常见错误解决办法

    如果輸入$ git remote add origin git@github.com:djqiang(github帳號名)/gitdemo(項目名).git 提示出錯信息:fatal: remote ...

  2. SQLite学习网址

    http://www.runoob.com/sqlite/sqlite-data-types.html

  3. Apache .htaccess语法之RewriteRule

    [说明]定义重写的规则[语法]RewriteRule Pattern rewritePattern [flags] # 开启 rewrite 功能 Options +FollowSymlinks Re ...

  4. hdu_5889_Barricade(最小割+最短路)

    题目链接:hdu_5889_Barricade 题意: 有n个点,m条边,每个边的长度都为1,每个边有一个消耗w,如果要阻断这条路,那么就会消耗w,现在让你阻断点1到点n的所有最短路,问你最小的消耗是 ...

  5. 三、ASP.NET MVC Controller 控制器(二:IController控制器的创建过程)

    阅读目录: 1.开篇介绍 2.ASP.NETMVC IControllerFactory 控制器工厂接口 3.ASP.NETMVC DefaultControllerFactory 默认控制器工厂 4 ...

  6. IOS真机Profile时调用树中的对象只是显示地址,没有显示symbol name

    解决问题的办法: 1.确认工程设置中的Scheme,profile选项对应的是debug版本还是release版本 2.确认工程设置中debug版本或者release版本是否生成了符号表 " ...

  7. DX shader根据顶点设置颜色

    matrix ViewProjMatrix; vector Blue = {0.0f, 0.0f, 1.0f, 0.0f}; struct VS_INPUT { vector position : P ...

  8. 转delphi中nil的用法

    转自:http://blog.csdn.net/haiou327/article/details/6666124 delphi中nil的用法 和C++中的NULL一样的意思,指空值,它和0值不一样-- ...

  9. chapter 13_1 算术类的元方法

    假设用table来表示集合,用function去计算集合的交集.并集. 为了保持名称空间的整齐,将这些函数存入一个名为Set的table中. 现在,假设用“+”来计算两个集合的并集,那么就要让所有用于 ...

  10. Mainline/Stable/Legacy

    Nginx官网提供了三个类型的版本Mainline version:Mainline 是 Nginx 目前主力在做的版本,可以说是开发版Stable version:最新稳定版,生产环境上建议使用的版 ...