Common Boardсколько у кого на тесте 6 60 30 20 10 0 0 ?? 54 27 18 0 0 0 Aleksandr Kim: You got AC? Edited by author 15.10.2011 17:30 wrong answer 4 Make sure you round the numbers down. I got wa 4 too. 73 21 4 0 0 0 But i have WA#9 73 21 4 0 0 0 but i have wa#9 My AC program gives 73 21 4 0 0 0 сколько у кого на тесте 6 60 30 20 10 0 0 ?? My code give : 50 25 16 8 0 0 The right answer for 6 60 30 20 10 0 0 is 73 21 4 0 0 0 I can confirm it with a code that got AC. If you get that result, and still get WA9 - add 0.00001 to the result before you cast it to int. Any one yes test? how about this one sample 5 5 3 3 3 3 ? this ans right 76 5 5 5 5? Edited by author 15.10.2011 14:59 I have 76 5 5 5 5 too, but WA#9 also too my solution also WA 9 test 76 5 5 5 5 too Edited by author 15.10.2011 15:59 Edited by author 15.10.2011 15:59 Mine gives 76 6 6 6 6 but WA 4 :) Edited by author 15.10.2011 16:19 my solution also WA 9 test 76 5 5 5 5 too mine gives 100 0 0 0 0 You've got the AC? as may be the answer? if all friends and Dan drank equally, then each are drank at 2.8 liters => each of them has bought more than drinking sorry for bad english :) I think it should be 100 0 0 0 0. Because everyone drank 3,8l and 4 of them bought 3l and Dan doesn't have to pay them. Edited by author 15.10.2011 17:10 Why? They brought 5+3+3+3+3 = 17, so everyone drank 17/6 = 2,8(3). George_Aloyan[PTSObninsk] is rigth This wtf situation from precision. Эта всё из-за точности. For example: Например: 4.99999999999999999999999999 But in real this is 5. When this are arounded in floor we get 4. Но на самом деле это число 5. А при округлении вниз получаем 4. So! Итак! This get WA9 floor(100.0*(a[i]-half)/mt); But this get AC floor(100.0*(a[i]-half)/mt+0.0001); P.S.: get 10 times WA9 =) Edited by author 15.10.2011 18:19 Edited by author 15.10.2011 18:19 Edited by author 15.10.2011 18:20 This wtf situation from precision. But this get AC floor(100.0*(a[i]-half)/mt+0.0001); Thank you very much. AC Thanks a lot, but really a strange situation)I understand the problem now, but... *Started reversing my solution* :) +0.0001 gave me WA#11 but +0.00001 gives AC ;) Friends! Problem can be solved easy in int type only without any 0.0001 and so on. Multiply all by common denumenators and have joy of AC. min multiplied coefficient is 5 - to get the AC=)(on Java) on c++ I used coefficient - 1000 Edited by author 15.10.2011 22:00 Thanks, I had a WA#5, added +0.0001 and got AC Hi, everyone! I had WA#9 too, but I wrote 'long double' instead of 'double' and got AC. It means it was precision's trouble. Edited by author 23.11.2017 18:25 I had the same problem. changing double to long double didn`t help, but adding 0.0001 to the result before casting it to int got my code AC. Apparently it`s an epsilon problem. AC program 76 5 5 5 5 My AC program answers to the test:5 5 3 3 3 3 76 5 5 5 5 too. 10 + 24 + 27 + 9 + 24 + 12 - 24 - 24 - 12 - 27 - 9 24 3 3 3 3 3 3 9 9 1 5 + 8 + 6 + 8 - 8 - 8 8 2 2 2 6 9 + 10 + 10 + 10 - 10 - 10 + 5 - 10 - 5 + 123 10 10 10 10 10 5 5 1 123 The following test helped me to catch out-of-index run time exception in my solution: IN: 18 + 1 - 1 + 1 - 1 + 1 - 1 + 1 - 1 + 1 - 1 + 1 - 1 + 1 - 1 + 1 - 1 + 32 - 32 OUT: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 32 1 I have two solutions! Time: 1.15 solution: numbers = [] for i in range(int(input())): numbers.append(int(input())) print_s = '' for n in numbers: if len(print_s) > 0: print_s += ' ' number = int((n * 2) ** 0.5) y = (number * (number - 1)) // 2 y2 = y + number y += 1 if n <= y2: print_s += '1' if n == y else '0' else: print_s += '1' if n == y + number else '0' print(print_s) Time: 1.15 solution: numbers = [] for i in range(int(input())): numbers.append(int(input())) print_s = '' for n in numbers: if len(print_s) > 0: print_s += ' ' length = 1 while n > length: n -= length length += 1 print_s += '1' if n == 1 else '0' print(print_s) Help me pls!! Edited by author 13.08.2022 10:14 n=int(input()) numbers=[] for i in range(0,n): numbers.append(int(input())) print_s = '' for n in numbers: if len(print_s) > 0: print_s += ' ' length = 1 while n > length: n -= length length += 1 print_s += '1' if n == 1 else '0' print(print_s) #include <iostream> #include <algorithm> using namespace std; int main(){ int n, half, votes, q[101]; cin >> n; half = (n/2) + 1; for (int i=0; i < n;i++) cin >> q[i]; sort(q,q+n); for (int i =0;i<half;i++) votes += (q[i]/2) + 1; cout << votes; return 0; } Every time I submit a super-efficient solution that is accepted, in the rating list there are more efficient solutions written in languages that are not supported now. Everybody knows that older compilers like Intel C++ 7 generate code that takes less RAM and is a little faster than any supported C++ compiler. It would be fair, if the Solutions rating list support an option to filter only solutions, implemented in currently supported languages and compilers. Administrators, please consider it. Cheers! If you look at the statement, it says "Triviality of a natural number N is the ratio of the sum of all its proper divisors to the number itself. Recall that a proper divisor of a natural number is the divisor that is strictly less than the number.". Therefore, triviality of 1 should be 0 / 1 == 0, since 1 doesn't have any divisor strictly less than itself. However, I couldn't get an AC (WA4) until I changed the line if (I == 1) ans = 0 to if (I == 1) ans = 1. So, either the statement or the tests are broken. Edited by author 05.08.2022 19:55 Edited by author 05.08.2022 19:55 I'm not an admin. You must write the number with minimal triviality. Triviality(1) == 0, that means you have to print 1 because 1 is number with minimal triviality. But you try to print the triviality of 1(i.e. 0). The statement is correct. using System; class Progran { public static void Main() { int Size = int.Parse(Console.ReadLine()); sbyte[] FirstNumber = new sbyte[Size + 1]; for (int i = 0; i < Size; i++) { string[] s = Console.ReadLine().Split(' '); FirstNumber[i + 1] = (SByte)(sbyte.Parse(s[0]) + sbyte.Parse(s[1])); } for (int i = Size; i > 0; i--) if (FirstNumber[i] >= 10) { FirstNumber[i - 1]++; FirstNumber[i] -= 10; } for (int i = 0; i < Size; i++) Console.Write(FirstNumber[i + 1]);
} } Edited by author 31.05.2022 12:17 I ported this code to c++ and got AC ?! Edited by author 31.05.2022 15:01 I finally got accepted it on a C#!! Main memory issue here are always any Strings! Awoid using Console.ReadLine() in cycle. For some reason, .net sometimes does not use string interning. I got below accepted using only Console.Read() byte-by-byte: class Program { static int N = 0; static byte[] Digs1 = null; static char m_Zero = '0'; static void _ReadData() { string v_Str = Console.ReadLine(); if (v_Str == null) return false; N = Int32.Parse(v_Str); Digs1 = new byte[N]; int v_TmpVal = 0; // Fill Digs for (int i = 0; i < N; i++) { v_TmpVal = Console.Read(); Digs1[i] = (byte)(Convert.ToChar(v_TmpVal) - m_Zero); Console.Read(); v_TmpVal = Console.Read(); Digs1[i] += (byte)((Convert.ToChar(v_TmpVal) - m_Zero) * 10); Console.Read(); //#13 Console.Read(); //#10 } static void SolveProblem() { bool v_AddOne = false; bool v_NextAddOne = false; byte v_First = 0; byte v_Second = 0; for (int i = Digs1.Length - 1; i >= 0; i--) { v_First = (byte)(Digs1[i] % 10); v_Second = (byte)(Digs1[i] / 10); v_AddOne = (v_First + v_Second + (v_NextAddOne ? 1 : 0)) > 9; Digs1[i] = (byte)((v_First + v_Second + (v_NextAddOne ? 1 : 0)) % 10); v_NextAddOne = v_AddOne; } } static void Main(string[] args) { _ReadData(); SolveProblem();
for (int i = 0; i < N; i++) { Console.Write(Digs1[i]); } } Hi, I`m happy for you. And it`s great that you are sharing your thoughts. However, you are not helping anyone by posting your code. Please don`t do it, and we all will be happier. Input: 14 4 learn 1 1 clone 1 learn 2 2 rollback 2 rollback 2 rollback 1 clone 2 learn 1 3 learn 2 4 relearn 3 relearn 3 check 1 check 2 check 3 Output: 3 4 2 3 5 -> 4 5 3 -> 5 1 5 -> 0 5 1 -> 1 10 10 -> 18 99999 99999 -> 199996 2147483647 2147483647 -> 4294967292 I hope it helps! in tree sum of vertex <= n + n/2 + n/4 +... = n*(1 + 1) = 2n Try below test with empty line as a text: --- start of input --- world # --- end of input --- Be careful, input in HEX can be presented as: 77 6F 72 6C 64 0D 0A 23 0D 0A 0D 0A The answer is: --- start of output --- 0 --- end of output --- Be careful about an empty line before 0. I got stuck with RE#15 (dp+dfs). Non-recursive algo with same idea got AC. Hope this information helped. I don't use ";" in the end. I use Console.Write() and not Console.WriteLine(). According to the interpreter my PIBAS programm is correct. Still I've got WA#1. I'd like to have some hints from people with C# AC. Disregard that. I don't understand how I checked my program a dozen times and didn't see the obviously wrong length of last substring! Funny thing about the interpreter provided by DR. Zhihua Lai: it does not react to substring length which is higher than the length of an actual string. That's why my PIBAS programm worked well in interpreter but gave me WA1 here. Bitsets instead of binary_search helped me found = False s= str(input()) for k in range (2, 37): try: h = int(s, k) if h%(k-1)==0: print(k) found = True break except: pass
if not found: print('No solution')
|
|