URAL 1925. British Scientists Save the world

Source: Internet
Author: User

1925. British Scientists Save the world
Time limit:1.0 Second
Memory limit:64 MB
The world was in danger! Aliens threw a mysterious device to Earth NYears ago. Every year a unknown sign appeared on its screens and it started to make threatening sounds until someone entered somethin G on its keyboard. It lasted till now. But recently British scientists has found out of that device is a bomb which are capable to destroy we world in Split s Econd. The signs, which the device displays on it screen, is 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 Le SS than the number shown on the screens by. Fortunately, aliens decided that it takes a lot of computing resources to check whether the input number is correct every Year. That's why the test was carried out once in N+ 1 years. Moreover, they check only then the sum of all numbers entered since the last Test matches the expected one. The good news is this all symbols, which the bomb showed, and all numbers, which were entered, were recorded and the Scien Tists already finished decrypting. Recently a number kAppeared on mysterious device's screen and the scientists is sure that this time can be a fatal one. So, you had a chance to save the world by finding-what number should is entered in order-avoid an explosion. Inputthe first line contains, positive integers N, k. In the next NLines there is pairs of numbers b I, g I( b Iis the number shown on device ' s screen, g IIs the number entered in the I-th year). All the integers in the input data does not exceed 100.OutputOutput one nonnegative an integer to save the world from the Explo Sion. If There is no such number output "Big bang!". Samples
input Output
6 53 13 15 36 55 57 2
3
1 34 6
Big bang!




Analysis: Reading comprehension questions ...



AC Code:

#include <cstdio>int main () {    #ifdef sxk        freopen ("In.txt", "R", stdin);    #endif//sxkint N, K, sum1, Sum2, A, B;while (scanf ("%d%d", &n, &k) ==2) {sum1 = sum2 = 0;for (int i=0; i<n; i++) {s CANF ("%d%d", &a, &b); Sum1 + = a;sum2 + = b;} Sum1 + = k;if (sum1 >= sum2 + (n + 1)) printf ("%d\n", sum1-sum2-2* (n + 1)); else puts ("Big bang!");} return 0;}



URAL 1925. British Scientists Save the world

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.