码迷,mamicode.com
首页 > 其他好文 > 详细

URAL 1925. British Scientists Save the World

时间:2015-03-11 08:13:32      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:

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 numbersbigi (bi is the number shown on device‘s screen, gi 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;
}



URAL 1925. British Scientists Save the World

标签:

原文地址:http://blog.csdn.net/u013446688/article/details/44193799

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!