Общий форум"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%') If my teacher is watching this post, sorry. Bruteforcing length gives WA, bruteforcing angle gives AC I checked several times and everything is working correctly, help me def encryption(txt): cipher = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
encryption_list = [] for i in txt: encryption_list.append(cipher[i]) c = d = c1 = 0 encryption_last_list = [] for i in encryption_list: if d == 0: d += 1 c = i i -= 5
if i < 0: i = 25 - abs(i) encryption_last_list.append(i)
else: c1 = i i -= c c = c1 if i < 0: i = 26 - abs(i) encryption_last_list.append(i)
decodding_list = [] for i in encryption_last_list: for k, v in cipher.items(): if v == i: decodding_list.append(k)
return decodding_list text = input() if len(text) <= 99: c = '' output = encryption(text.lower()) for i in output: c += i print(c) can anyone please explain the solution which uses the coordinates i think ... Edited by author 24.01.2023 20:46 Edited by author 24.01.2023 20:46 Edited by author 24.01.2023 20:46 I get WA 1 with calculating distance in this way for(int i=0;i<len;i++) { ans+=pow(((int)(buf[i]-'0')),3); } while accepted in this way for(int i=0;i<len;i++) { ans+=(buf[i]-'0')*(buf[i]-'0')*(buf[i]-'0'); } WHY?!!!! Is this a bug on judge or bug in function?!! the compiler is g++ why not try this ans+=round(pow(((int)(buf[i]-'0')),3)); Notice, that +1 and -1 mean not victory and defeat states. INPUT 2 L 1 +1 OUTPUT +1 4 3 1 2 2 3 3 4 Luck is possible |
|