|
|
Just prepare the equation as described and solve for c=x, display_sum + k - (entered_sum + x) == (n + 1) * 2; display_sum + k - entered_sum - x = 2 * n + 2; x = -2 * n - 2 + display_sum + k - entered_sum; if x < 0 then Big Bang! n,k = map(int, input().split()) kol = 0 u = 1 for i in range(n): a, b = map(int, input().split()) if a - b == 2: kol += u else: u = 0 if kol == 0: print('Big Bang!') else: print(kol) Определим переменную difference Затем для каждого элемента истории прибавляем к difference разницу между числом с компьютера - 2 и введённым числом В конце проверяем k - 2 + difference, если оно меньше нуля, то мы в пролете, иначе вывести число #include <iostream> using namespace std; int main() { int n, k; int i; int show, type; int showTotal = 0, typeTotal = 0; int neededType; cin >> n >> k; for ( i = 1; i <= n; i++) { cin >> show >> type; if (show - type == 2) showTotal = typeTotal = 0; else { showTotal += show; typeTotal += type + 2; } } neededType = k + showTotal - typeTotal - 2; if (neededType > 0 && neededType < 101) cout << neededType << endl; else { cout << "Big Bang!" << endl; } return 0; } maybe problem in this neededType > 0 || neededType < 101 UPD: result must be only bigger than zero! i have AC) Edited by author 21.01.2020 23:21 thanks Result may be greater than 100 Hey,could you help me? Do you say about your problem? Result may be greater than 100 #include <iostream> using namespace std; int main(){ int n(0),m(0),last(0),temp_f(0),temp_s(0),end_(0); cin >> n >> m; for(int i = 0;i<n;++i){ cin >> temp_f >> temp_s; last += temp_f-2-temp_s; } end_ = last + (m - 2); if(end_ < 0)cout << "Big Bang!"; else cout << end_; return 0; } Why the 2nd sample's answer is Big Bang? But why realy? I cant understand and could you please explain the first test too? Because the expected sum is 4+3-2*2(sum of the numbers shown on the screen+k-(n+1)*2) while the real sum is 6+x(the sum of the inputed numbers+the number YOU have to input), but they have to be equal: 4+3-2*2=6+x 7-4=6+x x=-3, but the answer is non-negative, so it is "Big Bang!". (in first sample you have 3+3+5+6+5+7+5-7*2 as the expected sum, and 1+1+3+5+5+2+x as the real sum: 3+3+5+6+5+7+5-7*2=1+1+3+5+5+2+x 34-14=17+x x=20-17 x=3 ) X is the output number. Or at least that is how i understood this problem. edit: what is the limit of X??? Edited by author 27.10.2012 15:43 You answer is kick ass. How can you figure out something like that? I check again and again, and it seems gibberish to me. I don't understand (n+1)*2. Can you tell me Why do you subtract (n+1)*2; Cause we subtracted 2 n+1 times the problem says " Moreover, they check only that the sum of all numbers entered since the last test matches the expected one." Thus should the new number entered in the test to check whether there is a big bang or not? If we have to take into account last input i.e. k value the the problem statement is incorrect. Please could someone explain this. Finally AC! understood the problem now. I wa#4, plz explain the problem for me Finally AC! understood the problem now. Can you give explanation?, please! Please give me some tests for #Wa4 ! "which is less than the number shown on the screen by two" means 1/2 or n-2? Может ли искомое число быть отрицательным |
|
|