zoj1110 Dick and Jane
来源:互联网 发布:手机版四库全书软件 编辑:程序博客网 时间:2024/05/10 12:46
Description
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
Source
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.
这就是暴力的原因。#include <iostream>
#include<cstdio>
using namespace std;
int main()
{
int a[4],i,j,k,s,p,y;
while(scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])!=EOF)
{
for(i=0;i<=1;i++)
for(j=0;j<=1;j++)
for(k=0;k<=1;k++)
{
y=(a[3]+12-a[1]-a[2]-j-k)/3;
p=y+a[1]+j;
s=p+a[0]+i;
if(y+p+s==a[3]+12)
{
printf("%d %d %d\n",s,p,y);//有多种年龄的组合可能,只取其中一种,故跳出。
// break;//break只能跳出一层循环。用goto
goto xx;
}
}
xx:;
}
return 0;
}
- zoj1110 Dick and Jane
- Dick and Jane
- 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
- ZOJ 1110 Dick and Jane 胡乱枚举实现。
- zoj1110
- Light OJ 1175 Jane and the Frost Giants
- 对不起,jane
- Jane's words
- SUMMARY OF JANE EYRE
- Jane Eyre(A)
- How are you doing, Jane?
- 英语练习30 Poor Dick
- DECODE,case when
- BZOJ 2038 小Z的袜子(hose) (莫队离线)
- HDU 4512 吉哥系列故事——完美队形I
- C++ cin对象
- C++ 智能指针详解
- zoj1110 Dick and Jane
- Hadoop的Python框架指南
- tomcat 配置下载链接
- POJ 2457--Part Acquisition 【spfa最短路 + STL路径输出】
- openssl编程之服务端
- IOS开发中的沙盒机制
- [Java Web]EasyUI中Calendar预设时间的解决
- WPF- Dispatcher
- 网络请求5步