URAL 1925. British Scientists Save the World

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;
}



用代码解决这个问题The program committee of the school programming contests, which are often held at the Ural State University, is a big, joyful, and united team. In fact, they are so united that the time spent together at the university is not enough for them, so they often visit each other at their homes. In addition, they are quite athletic and like walking. Once the guardian of the traditions of the sports programming at the Ural State University decided that the members of the program committee spent too much time walking from home to home. They could have spent that time inventing and preparing new problems instead. To prove that, he wanted to calculate the average distance that the members of the program committee walked when they visited each other. The guardian took a map of Yekaterinburg, marked the houses of all the members of the program committee there, and wrote down their coordinates. However, there were so many coordinates that he wasn't able to solve that problem and asked for your help. The city of Yekaterinburg is a rectangle with the sides parallel to the coordinate axes. All the streets stretch from east to west or from north to south through the whole city, from one end to the other. The house of each member of the program committee is located strictly at the intersection of two orthogonal streets. It is known that all the members of the program committee walk only along the streets, because it is more pleasant to walk on sidewalks than on small courtyard paths. Of course, when walking from one house to another, they always choose the shortest way. All the members of the program committee visit each other equally often. Input The first line contains the number n of members of the program committee (2 ≤ n ≤ 105). The i-th of the following n lines contains space-separated coordinates xi, yi of the house of the i-th member of the program committee (1 ≤ xi, yi ≤ 106). All coordinates are integers. Output Output the average distance, rounded down to an integer, that a member of the program committee walks from his house to the house of his colleague.
最新发布
05-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值