URAL 1925. British Scientists Save the World

在1925年,英国科学家们面对一个由外星人投掷到地球上的神秘装置展开研究,该装置每年显示一个数字并威胁爆炸。科学家们发现这实际上是一个定时炸弹,并且找到了避免爆炸的方法——输入一个特定的数字。本文详细介绍了如何通过算法计算出这个数字。

1925. British Scientists Save the World

Time limit: 1.0 second
Memory limit: 64 MB
The world is in danger! Aliens threw a mysterious device to Earth  n years ago. Every year an unknown sign appeared on its screen and it started to make threatening sounds until someone entered something on its keyboard. It lasted till now. But recently British scientists have found out that this device is a bomb which is capable to destroy our world in split second. The signs, which the device displays on its screen, are numbers and for input the device expects numbers as well.
The aliens invented a smart protection: every year, in order to avoid an explosion, you had to enter a number, which is less than the number shown on the screen by two. Fortunately, aliens decided that it takes a lot of computing resources to check whether the input number is correct every year. That is why the test is carried out once in  n + 1 years. Moreover, they check only that the sum of all numbers entered since the last test matches the expected one.
The good news is that all symbols, which the bomb showed, and all numbers, which were entered, were recorded and the scientists already finished decrypting. Recently a number  k appeared on mysterious device's screen and the scientists are sure that this time can be a fatal one. So, you have a chance to save the world by finding out what number should be entered in order to avoid an explosion.

Input

The first line contains two positive integers  nk. In the next  n lines there are pairs of numbers b ig i ( b i is the number shown on device's screen,  g i is the number entered in the  i-th year). All the integers in the input data do not exceed 100.

Output

Output one nonnegative integer to save the world from the explosion. If there is no such number output “Big Bang!”.

Samples

input output
6 5
3 1
3 1
5 3
6 5
5 5
7 2
3
1 3
4 6
Big Bang!




解析:阅读理解题。。。



AC代码:

#include <cstdio>

int main(){
    #ifdef sxk
        freopen("in.txt", "r", stdin);
    #endif //sxk

	int n, k, sum1, sum2, a, b;
	while(scanf("%d%d", &n, &k)==2){
		sum1 = sum2 = 0;
		for(int i=0; i<n; i++){
			scanf("%d%d", &a, &b);
			sum1 += a;
			sum2 += b;
		}
		sum1 += k;
		if(sum1 >= sum2 + 2*(n + 1)) printf("%d\n", sum1 - sum2 - 2*(n + 1));
		else puts("Big Bang!");
	}
	return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值