ZOJ 1110 Dick and Jane
来源:互联网 发布:路由器1900端口入侵 编辑:程序博客网 时间:2024/05/20 22:26
Dick is 12 years old. When we say this, we mean that it is at least twelve and not yet thirteen years since Dick was born.
Dick and Jane have three pets: Spot the dog, Puff the Cat, and Yertle the Turtle. Spot was s years old when Puff was born; Puff was p years old when Yertle was born; Spot was y years old when Yertle was born. The sum of Spot's age, Puff's age, and Yertle's age equals the sum of Dick's age (d) and Jane's age (j). How old are Spot, Puff, and Yertle?
Each input line contains four non-negative integers: s, p, y, j. For each input line, print a line containing three integers: Spot's age, Puff's age, and Yertle's age. Ages are given in years, as described in the first paragraph.
Sample Input
5 5 10 95 5 10 105 5 11 10
Output for Sample Input
12 7 213 7 213 7 2
按理想状态,设yertle为i岁,那么sp为i+y,pu为i+p,然后12+j-3*i-y-p就是我们要求的i的表达式
若这个式子被3整除,那么大家都正好,否则要么sp少1或者pu少1或者都少1.
若y-p==s那么说明sp没进位,那么再经相同的年数,sp比pu要先进位,所以此时sp++;
若y-p>s那么说明sp进位了,那么经过相同的年数,pu比sp先进位,所以pu++
int main()
{
int s,p,y,j,d;
int sp,pu,ye;
while(scanf("%d%d%d%d",&s,&p,&y,&j)!=EOF)
{
d=12+j-p-y;
ye=d/3;
pu=ye+p;
sp=ye+y;
if(d%3==1)
{
if(y-p>s)
pu++;
else
sp++;
}
else if(d%3>1)
{
pu++;
sp++;
}
printf("%d %d %d\n",sp,pu,ye);
}
return 0;
}
- zoj 1110 Dick and Jane
- zoj 1110 Dick and Jane
- ZOJ 1110 Dick and Jane
- ZOJ 1110 Dick and Jane
- ZOJ 1110 Dick and Jane
- ZOJ 1110 Dick and Jane
- ZOJ 1110 Dick and Jane 胡乱枚举实现。
- Dick and Jane
- Dick and Jane
- zoj1110 Dick and Jane
- Light OJ 1175 Jane and the Frost Giants
- 对不起,jane
- Jane's words
- SUMMARY OF JANE EYRE
- Jane Eyre(A)
- ZOJ 2104 ZOJ 1110
- ZOJ 1093 Monkey and banana
- zoj 1028 Flip and Shift
- 3百大战:度娘如何接招?
- 使用位逻辑运算来实现位向量
- 去掉A标签点击后的虚框
- 谈谈项目管理中遇到的人的性格缺陷
- ZendFramework学习第三章(核心组件—过滤器之过滤器的使用方法)
- ZOJ 1110 Dick and Jane
- 高速学英语- 大脑的不同学习机制
- IOS上的socket通信 CFsocket
- NSTimer使用总结(完)
- 2010 Word打开文档结构图.
- Android中px与dip,sp与dip等的转换工具类
- poj 1017 Pakets
- Android的编译系统
- poj 2478 Farey Sequence (欧拉函数)