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 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;
}
时间: 2024-11-10 23:28:20

URAL 1925. British Scientists Save the World的相关文章

ural 1272. Non-Yekaterinburg Subway

1272. Non-Yekaterinburg Subway Time limit: 1.0 secondMemory limit: 64 MB A little town started to construct a subway. The peculiarity of the town is that it is located on small islands, some of them are connected with tunnels or bridges. The mayor is

URAL 1707. Hypnotoad&#39;s Secret(树状数组)

URAL 1707. Hypnotoad's Secret 题目链接 题意:这题设置的恶心不能多说,构造点和矩形,大概就是问每个矩形里面是否包含点 思路:树状数组,把点排序,按y轴,在按x轴,在按询问,这样每次遇到一个点就在相应的扫描线上加,遇到查询就询问出左边到这个点位置的,就能预处理出每个点左下角包含的点的个数,然后每个矩形再利用容斥原理去搞一下即可 代码: #include <cstdio> #include <cstring> #include <algorithm&

URAL 1930 Ivan&#39;s Car(BFS)

Ivan's Car Time limit: 1.5 secondMemory limit: 64 MB The world is in danger! Awful earthquakes are detected all over the world. Houses are destroyed, rivers overflow the banks, it is almost impossible to move from one city to another. Some roads are

ural 1249. Ancient Necropolis

1249. Ancient Necropolis Time limit: 5.0 secondMemory limit: 4 MB Aerophotography data provide a bitmap picture of a hard-to-reach region. According to the suggestions of scientists, this region is a cemetery of an extinct civilization. Indeed, the p

8 Productivity hacks for Data Scientists &amp; Business Analysts

8 Productivity hacks for Data Scientists & Business Analysts Introduction I was catching up with one of my friends from a past organization. She had always been interested in data science, but was only able to break into it about 10 months ago. She h

URAL 1313 Some Words about Sport (阅读理解)

1313 Some Words about Sport Time limit: 0.5 second Memory limit: 64 MB Ural doctors worry about the health of their youth very much. Special investigations showed that a lot of clever students instead of playing football, skating or bicycling had par

Software development skills for data scientists

Software development skills for data scientists Data scientists often come from diverse backgrounds and frequently don't have much, if any, in the way of formal training in computer science or software development. That being said, most data scientis

URAL 2092 Bolero 贪心

C - Bolero Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice URAL 2092 Description Winter in Yekaterinburg is the longest time of the year. And everyone spends long winter evenings in his own way. Den

ural 2062 Ambitious Experiment

2062. Ambitious Experiment Time limit: 3.0 secondMemory limit: 128 MB During several decades, scientists from planet Nibiru are working to create an engine that would allow spacecrafts to fall into hyperspace and move there with superluminal velocity