20150419武大邀请赛之网络赛 H - Things after school

Description
Alice, Fzz’s daughter is a primary school student. Fzz loves his daughter so much that he drives to school every day exactly on time when the school day is over, which means when Fzz arrives school the school day is exactly over.
It is the 100th anniversary celebration of school today. After some interesting activities, the principal announce that school is over. Alice watches her watch, and she knows it is x minutes earlier compared to the time when the school day usually ends. She starts to go home.
After y minutes, she meets her Dad. Then she gets on the car. They go home happily by car.
When she arrives home, she finds it is z minutes earlier compared to the usual.

Alice is good at math. She wants to challenge her dad with some questions.
Now she gives two numbers of x, y, z and asks his father to calculate the third one.

For example, she says “dad, when y equals 30, and z equals to 20, what’s the x?”
Fzz gives the answer ‘40’ right after the question.
However it’s your turn. Can you calculate it?

Input
The input contains several cases.
First line contains an integer n, the number of test cases (n<=10000).

For each case, there are 2 integers and 1 character ‘?’. The first stands for x, the second stands for y, and the third stand for z.

 

Output

For each case, output in a single line with the answer to the ‘?’. It is guaranteed all the number will be positive integer no more than 1000000 (both Input & output).

 

Sample Input
3
? 30 20
40 ? 20

40 30 ?

 

Sample Output
40
30

20

 

Alice在放学后走了y分钟,遇到Fzz,然后提前了z分钟回到家。那也就是说从他们遇到的地方到学校是z/2分钟车程。(因为Fzz每天都在放学的那一刻刚好到达学校,而他们少走的路程就是2倍的相遇点到学校。)所以我们就有:x = y + z / 2。给定其2,求第三。

 

 

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        char x[30],y[30],z[30];
        int a,b,c,m,n;
        scanf("%s%s%s",x,y,z);
        if(x[0]=='?') {
            m=atoi(y);n=atoi(z);
            a=n/2+m;
            printf("%d\n",a);
        }
        if(y[0]=='?') {
            m=atoi(x);n=atoi(z);
            b=m-n/2;
            printf("%d\n",b);
        }
        if(z[0]=='?') {
            m=atoi(x);n=atoi(y);
            c=(m-n)*2;
            printf("%d\n",c);
        }
    }
    return 0;
}

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值