Общий форумa=input().split('\n') j=[] for x in a: for xx in x.split(" ") : if(len(xx)>0): j.append( float(xx)**0.5) for i in range(len(j)-1,-1,-1): print(format(j[i],'.4f'))
Time limit test 20 failed on python. Rewrited on C# - everything OK. Edited by author 04.10.2019 02:08 Edited by author 04.10.2019 02:08 I tried to solve this problem in java since we have to accept as many number of lines given in input I wrote a while loop as follows while (in.hasNextLine()) // in is scanner object { // read input and do stuff } but this loop seems to run forever how do I stop the loop from running. Several highly optimized solutions were TLE in Python3.6, though on local run in Linux it shows half of a time on your server. Is there some mistake? It is definitely broken, because same code works in Python 2 It is not broken. I managed to solve it with Python 3.6 There is one more way to solve it in Python 3 without sorting #include <iostream> #include <stack> using namespace std; int main() { unsigned short n1, n2, n3; int a, n=0; stack<int> group1; cin >> n1; for (int i = 0; i <n1; i++) { scanf_s("%d", &a); group1.push(a); } stack<int> group2; cin >> n2; for (int i = 0; i < n2; i++) { scanf_s("%d", &a); group2.push(a); } stack<int> group3; cin >> n3; for (int i = 0; i < n3; i++) { scanf_s("%d", &a); group3.push(a); } while (!group1.empty()) { if (group1.top() == group2.top()) { if (group1.top() == group3.top()) { n++; group1.pop(); group2.pop(); group3.pop(); if ((group1.empty()) || group2.empty() || group3.empty()) break; } else if (group1.top() > group3.top()) { group1.pop(); group2.pop(); if (group1.empty() || group2.empty()) break; } else group3.pop(); } if (group1.top() > group2.top())group1.pop(); if (group1.empty()) break; if (group1.top() < group2.top())group2.pop(); if (group2.empty()) break; } cout << n;
} what's wrong? after else group3.pop(); if (group3.empty()) break; accapte We have got 3 distinct number, A < B < C. Let's imagine that the minimum difference Z = (C - B) goes between numbers A and B, closer to B, so new sequence will be A < Z < B < C. And the next minimum difference Y = (B - Z), goes between A and Z, closer to Z, A < Y < Z < B < C and so on. You see Y + Z = B, Z + B = C, the next number in the sequence (in order from left to right) is equal to the sum of current and previous members (looks like Fibonacci numbers). Now try to find the sequence with described property. Look at the example: 1 4 6 10 16 26 ... We can continue this sequence until the last two members will be 519390993822245170 and 840392281454979346. Their sum is more than 10^18. It takes only 83 iterations to build this sequence. The test case would be: 1 519390993822245170 840392281454979346 So, in the worst case, the number of iteration N < 100. The naive algorithm, when we just put the minimum diff to the array and sort it again will work. The time complexity will be O(N^2 log N). Edited by author 01.10.2019 14:24 helped for me 3 17 answer 1 3 3 18 17 I can't find mistake, and have WA on test 7. Someone can give some cases? Edited by author 13.11.2011 18:38 try 5 4 1 2 3 4 5 1 2 3 4 asn = 1 //pseudo code divider = first_input-1; dividend = second_input-1; result: divider + dividend - FindCrossesOnTheWay(dividend,divider) *FindCrossesOnTheWay if(divider < dividend) swap() for(i=1;i<=divider;i++) if((dividend * i) % divider == 0) crosses++ I've implemented this problem two different ways and I have WA9 on both of them. I'm possibly interpreting the problem wrong, but I've read the problem over and over again and I cannot come up with an alternative interpretation. Can someone please shine some light? Если у кого ещё такая проблема есть, то это,как вариант, связано с нечетным n (последний человек ни разу не дежурит) #include <iostream> #include <string> using namespace std; int main() {string s; int o=0; getline(cin, s); string b1 = "adgjmpsvy. "; string b2 = "behknqtwz,"; string b3 = "cfilorux!"; for (int k=0; k<s.size();k++) { if (b1.find(s[k]) != string::npos) o++; if (b2.find(s[k]) != string::npos) o+=2; if (b3.find(s[k]) != string::npos) o+=3; } cout<<o; return 0; } Which algorithm?? Help I need help also. As i see you have solved it. Could you please help me? Try this: 3 2 of sweets 5 of milk 1 of sausage 4 6 of milk 3 of milk 1 of milk 3 of sweets Correct answer is: 8 Good luck! i have used long long and scanf still wa who can help me?plz 0.0 Below test helped me to pass test 5 after WA verdict: 5 6 4 0 6 0 3 0 7 0 8 department 1 10 1 department 2 10 1 department 3 10 1 department 4 10 1 department 0 7 10 department 0 500000000 1000000000 As you can check manually, correct answer is: 1000000014 1000000017 1000000014 1000000018 1000000019 it really helps,thanks bro I have 2 questions. 1. As AI Cash asked, can each design have two or more points with the same location? 2. "the pre-jury wants to find the designs which only differ in rearrangement of points and their affine transformation that doesn't change the orientation" does it mean that two designs (P1, P2, P3, ..., Pm) and (Q1, Q2, Q3, ..., Qm) will be considered same if there is an affine transformation Qi=A*Pi+b for all i such that A is matrix 2x2 that detA>0 ? Thank you from Thailand. :) Edited by author 22.09.2019 20:01 Hello, today i'm gonna tell ya how to solve this easy task! We can notice: 1 has places 0,1,3,6,10 etc. 0*8+1 = 1; 1*8+1 = 9; 3*8+1 = 25; 6*8+1 = 49; 10*8+1 = 81; I gave you the advice! So, it's easy! Good luck! If i hepled you, you may subscribe to my VK, Facebook, Instagram, Odnoklassniks, Patreon, Twitter, Twitch, Steam, Battlenet, Goggle+ and Youtube channel, there you'll find more solutions for problems! "If there is a problem, we solve it!" (c). Every rights are reserved. what is wrong with test #27 ? try 1 10000 answer 25007071.3178118650 25007071.3178118655 for 1 10000. Accurate enough, but still wrong answer on test case #27. try 10000 1 may be In #27 system checks output format I changed my python solution print FLOATANS to print "%0.6f" % FLOATANS and get AC Edited by author 08.05.2013 14:10 I had wrong answer on test 27, but corrected it by using "long double" type There's my code [code deleted] Edited by moderator 23.10.2019 22:04 |
|