poj 3716 Panda's Birthday Present

Panda's Birthday Present
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 1200 Accepted: 796

Description

On Panda's Birthday party, he received a strange present from Jason. The present is a black box with 4 dices in it which is used to play a game. The dice in the box is unusual. Instead of the digits, only red or blue is painted on each side of the dice. Before the first round of the game, the box can repaint every side of every dice red or blue with equal probability. Then for each round of the game, the box will roll the 4 dices and tell the player the number of red side facing up, which is the point the player get. Now, Panda has play it for two rounds and he tell you the point he has got for each round. Can you tell him the expected point he can get for next round.

Input

The first line of the input is number of test case. Each test case contains two integers, pand q, which are the points Panda has got for the first two rounds.(0≤ p, q≤4)

Output

For each test case, output the expected point panda can get for the third round. Round the answer to the third digit after the decimal point.

Sample Input

2
2 2
4 4

Sample Output

2.000
2.571
#include <iostream>  

using namespace std;

int main()
{
int nCase;
int p, q;
double result;

scanf("%d", &nCase);
while(nCase--)
{
scanf("%d %d", &p, &q);
result= (p + q + 10) / 7.0;
printf("%.3lf\n", result);
}

return 0;
}
 

转载于:https://www.cnblogs.com/w0w0/archive/2011/11/23/2259871.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值