Общий форумmxw can be 1, and all w is about 10^9 and a can be 10^9, then in the worst case we need to withdraw the sum of 10^18 about 10^5 times, so long double should not fit, but it fits What is in test7? Edited by author 23.02.2023 13:59 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 Ans:- 1681 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 Ans:- 1271 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Ans:- 12870 You are very stupid!!! 0<ans<9 Don't repeat my mistake and remember that you must calculate prime numbers up to 10000 (not to 100!). Maybe this test will help you: 9797 1 1 1 1 1 1 1 1 1 Answer = 4 (9797 = 97 * 101) Sorry for my English :) Edited by author 04.04.2010 19:55 oh!!! thank you very much, i just calculate to sqrt(10000)... if you have WA in test4, you can try this. oh!!! thank you very much, i just calculate to sqrt(10000)... if you have WA in test4, you can try this. I just got accepted. It is enough to calc prime nums up to Num div 2. Because if Num not divided on any prime <= than Num div 2 then Num itself is a prime num. Edited by author 22.02.2023 12:10ilyas: Please don't call people stupid. Everyone makes mistakes; the author simply forgot to calculate modulo 10. Thanks for tests, I join. Input: 1 1 1 1 1 1 1 1 1 1 Output: 1 Input: 43 5 49 2 3 5 3 4 5 5 Output: 0 Input: 10000 10000 12 10000 10000 10000 13 10000 10000 29 Output: 2 Input: 99 101 102 103 104 105 106 107 108 109 Output: 6 My program passes all these test cases... Still I am getting wrong answer at 6th test. I have WA in test 13 Edited by author 21.02.2023 01:48 Anybody else? I guess it's the epsilon. But I failed all trial. test 27: x==kx &&y==ky good luck... After so many years, I tried my WA#27 code again. with G++ 9.2 x64 or Visual C++ 2019 x64, the same code got AC. Compilers!!! I got a question about the problem description. In other games, the losers hope to last the game longer for as many turns/rounds/moves as possible. In this game, is the losers' optimal move to (1) to minimize the difference, (2) to maximize theirselves' scores, or (3) to minimize the opponents' scores? Or are the 3 goals lead to the same move? Thanks. "Your task is to make the largest number of the Great Discoveries and maximally to delay the doomsday." Notice, that we are not only maximazing the period, but also the k^period. So we have to find strictly maximal "generator"/"primitive"/"первообразная"/"образующая". There can be problem with understanding the way of minimizing these values. But as period it divisor of (mod - 1), and there are many generator, and they are quite uniformly distributed, probably k^(mod - 1) will always be better, than some p^((mod - 1) / q), where p > k. #include<iostream> #include<iomanip> #include<bits/stdc++.h> #include<string> using namespace std; int main(){ float n, k; int mark, a; a=0; k=0; cin >> n; for(int i=0; i<n; i++){ cin >> mark; a+=mark; } cout << fixed; cout << setprecision(1); k+=a/n; if(a%5==0 && mark>=5){ cout <<"Named" << endl; } else if(mark>3 && k>=4.5){ cout <<"High"<<endl; } else if(mark<=3){ cout <<"None" << endl; } else{ cout << "Common" << endl; } return 0; } For those who have WA on test 7, please try following one: 4/2*3+ For n = 10 and k = 20, what should be the output? Well, obviously it's not 0! For this test case (n=10, k=20) answer is equal to 10. why? Can you please explain? I created every stack using pointers, but nodes in this stack saved data of ten last pushed elements, not of one last. So this is a stack of arrays and not the stack of single elements. Also I had an additional array of int[1000], that showed how many positions in last node of each stack is already used. Conclusion: you need to do such a struct of that has an array of ten elements and a pointer to previous node. On every push-call you should create another node(if previous is full) and add an element on the first open space of node, then increase the number of used positions. On every pop-call you should go to previous node and delete current node(if current node is empty) and print the last element of node, then decrease the number of used positions. Hope it'll help you. And I apologize for my poor english) Thank you!, now I got AC. =) a = input() row = [] for i in a: row.append(i) for i in range(len(row)): row[i] = int(row[i]) suml = row[0] * 100 + row[1] * 10 + row[2] sumr = row[3] * 100 + row[4] * 10 + row[5] if suml - sumr == 1 or sumr - suml == 1: print('yes') else: print('no') 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) const STACK_SIZE: usize = 128 * 1024 * 1024; fn run() { //... } fn main() { let child = std::thread::Builder::new() .stack_size(STACK_SIZE) .spawn(run) .unwrap(); child.join().unwrap(); } There were mentioned, that it is required 64-bit integer type. I also add, that it has to be unsigned, otherwise you get WA 8. Can somebody give me anti-greedy tests so that a greedy solution will not give correct answer? A test like #39? I'm sure that greedy is the right solution, i cannot find counter-test for my solution. I have same problem... Try: 3 1 1 6 3 2 2 4 ..or.. 3 1 2 4 3 2 0 4 Edited by author 08.04.2011 17:18 I have same problem and my program works for this input (both R possible, correct me if I'm wrong) and I would appreciate if someone would suggest why program is not working and/or give me more tests like #39. Edited by author 24.04.2011 02:46 Same problem... Can somebody give us some tests? Try this: 5 2 0 3 3 2 3 2 0 2 0 5 This one is also nice: 4 2 0 3 1 2 2 2 1 4 Great thanks to @BSoD Edited by author 01.02.2023 19:37 Edited by author 01.02.2023 19:37 Guess, why I had wasted 18 attempts? The exponent can have + sign: 1.3e+32 All bad wished to author. #include <iostream> #include<vector> #include<algorithm> using namespace std; int main() { int n, a, razn, k1 = 0, k2 = 0; cin >> n; vector<int>num; for (int i = 0; i < n; i++) { cin >> a; num.push_back(a); } sort(num.begin(), num.end()); int kol = 0; for (int i = 0; i < n - 1; i++) {//все камни кроме максимума kol += num[i]; } if (kol < num.back()) {//если все камни меньше самого максимального cout << num.back() - kol; } else if (kol == num.back()) {//если все камни pавны максимальному cout << 0; } else if (kol > num.back()) {//если все камни больше максимального k2 = num.back(); for(int i =n-2;i>=0;i--){ if (k1 < k2) { k1 += num[i]; } else if (k1 > k2) { k2 += num[i]; } else if (k1 == k2) { k1 = num[i]; k2 = 0; } } cout << abs(k1 - k2); } } //my program is fine solves any of my values. what is in test 5? здесь надо делать перебор битовыми масками Edited by author 28.01.2023 12:25 n, m = map(int, input().split()) a = [] b = [1] c = [] for i in range(m): f = int(input()) a.append(f) a = sorted(a) f = 0 for i in range(1, len(a)): if a[i] == a[i - 1]: b[f] += 1 elif a[i] != a[i - 1]: b.append(1) f += 1 for i in range(len(b)): b[i] = float(b[i] / m * 100) for i in range(len(b)): c.append('%.2f' % b[i] + '%') for i in range(n): try: print(c[i]) except: print('0.00%') |
|