Show all threads Hide all threads Show all messages Hide all messages |
Page 4 |
Why two equal Java codes give different results? (test #13) | Ivan Avdonin (Vologda ML) | 1820. Ural Steaks | 3 Aug 2015 07:09 | 1 |
First code gives wrong answer test #13. In the next code I changed System.out.print(2*n/k+2*n%k); and used Math.ceil() System.out.print((int)Math.ceil(2*(float)n/(float)k)); The code was accepted. What's wrong? Edited by author 03.08.2015 07:16 Edited by author 03.08.2015 07:17 Edited by author 03.08.2015 07:17 Edited by author 03.08.2015 07:17 Edited by author 03.08.2015 07:18 Edited by author 03.08.2015 07:18 Edited by author 03.08.2015 07:22 |
wtf WA TEST#8 PLS HELP ANYONE | Akash_Cross | 1820. Ural Steaks | 24 Sep 2015 22:49 | 5 |
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; //URAL STEAKS public class P { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); String line; int ans; line = br.readLine().trim(); String str[]; str = line.split(" "); int N = Integer.parseInt(str[0]); int K = Integer.parseInt(str[1]); if(2*N%K>1){ ans = (2*N/K)+1; }else{ ans = (2*N/K); } out.print(ans); out.flush(); } } При N = 1, K = 2 программа выдаёт 1, а должна 2 по условию задачи. Please give answer in English... if (n<=k) the answer is 2 |
Не принимает | Skrom | 1820. Ural Steaks | 23 Feb 2019 07:46 | 5 |
import java.io.*; import java.util.*; public class task { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int k = in.nextInt(); int t; if(n>=1 && k<=1000) { if((int) (n * 2.0 / k) == (n * 2.0 / k)) t = (int) (n * 2.0 / k); else t = 1 + (int) (n * 2.0 / k); out.print(t);
} out.flush(); } } Братан эту задачку на 1 вывод решить можно) зачем тебе эти условия Edited by author 29.10.2015 01:41 Я одного не пойму, как можно обжарить 3 бифа с обеих сторон за 3 минуты, если влазит на сковороду всего 2 шт???))) На первой минуте жаришь первые 2шт с одной стороны, на второй их же со второй. На третей минуте последний биф 1 сторона 4я минута 2я сторона 3го бифа!!. В итоге правильный ответ 4 минуты, а не 3 как написано в примерах. Изи. Смотри 1 и 2 это первые и вторые стороны бифов. B это номер бифа. Разделю их точкой первая минута: 1.1 1.2 вторая минута: 2.1 1.3 третья минута: 2.2 2.3 Я тоже также думал, пока не прочитал в дискуссии: http://acm.timus.ru/forum/thread.aspx?id=36182&upd=636324641214598077 1-я минута - Жарится одна сторона двух стейков.(1-я сторона) 2-я минута - Жарится один из первых стейков(2-я сторона) + третий стейк(1-я сторона) 3-я минута - Жарится второй из первых стейков(2-я сторона) + третий стейк(2-я сторона) |
Что тут не правильно? | Mesxi | 1820. Ural Steaks | 3 Jun 2015 12:00 | 1 |
i understand problem !!! Edited by author 03.06.2015 12:14 |
Help me please. Where is error? В чем ошибка? | timur1108 | 1820. Ural Steaks | 14 Jun 2015 04:44 | 2 |
var n,k,l:real; begin read(n,k); l:=(n*2/k); if trunc(l)=0 then write(2) else if frac(l)=0 then write(l) else write(trunc(l)+1); end. |
Don't cook steaks like that! | alextj | 1820. Ural Steaks | 11 Feb 2015 01:34 | 1 |
Whoever thought of this problem haven't fried steaks in real life. The only way to get an acceptable solution to 1820 is to cook the steaks somewhat similar to this order: Minute 1: St1A, St2A Minute 2: St1B, St3A Minute 3: St2B, St3B (where there are three steaks: St1, St2 and St3, and each having side A and side B). The problem with this is: After St2A side is cooked, it will be taken off the heat and cool down for one minute before cooking the other side, thus in the end the steak will be less cooked than stake 1 and 3. That's all sorts of wrong, you'll be ruining a good steak! :-D |
WA #8 java | mehdi_wm | 1820. Ural Steaks | 23 Jan 2017 20:07 | 4 |
import static java.lang.Math.*; import java.util.*; public class UralSteaks { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n,k; n=in.nextInt(); k=in.nextInt(); int t=(int)ceil(2*(float)n / (float)k); System.out.print(t); }
} help plz! |
When rounding (particularly test 13) | Roger Collins | 1820. Ural Steaks | 23 Jan 2015 11:00 | 1 |
Pay attention to your data types, and convert before ceil if needed. |
confusion | Garik | 1820. Ural Steaks | 11 Oct 2014 21:48 | 1 |
what is the difference?? to count as whole stakes or to count it with side. as i think this is the same problem but we get different answers to this question. |
to admins: yet another test | TwoEightNine [146110Butorov] | 1820. Ural Steaks | 19 Sep 2014 09:36 | 1 |
my first solution got ac, but with my test 3 78 it wrote 1 i think you should add some tests |
Моя мама сказала, что 3 котлеты за 3 минуты жарят только программисты. | IPRIT | 1820. Ural Steaks | 5 Aug 2014 16:28 | 2 |
:D моя ещё не знает, что я программно жарю котлеты :D |
for solve this problem you should know this... | mhg | 1820. Ural Steaks | 7 Jul 2014 17:22 | 1 |
1.you should consider total sides that must be fried instead the number of steaks. 2.with every pan we can fry one side of steak independently. for example if we have only 1 steak and 2 pan we can fry it in 1 minute or for 5 steaks and 6 pan we can do it for 1 minute. Edited by author 07.07.2014 17:30 Edited by author 07.07.2014 17:32 |
c++ Accepted answer(efficient and simple to understand)+explanation | Lawrence | 1820. Ural Steaks | 19 Oct 2014 06:37 | 3 |
[code deleted by moderator] You are interested in the number of sides, not steaks as total. First you calculate number of sides, then you calculate the remainder between it and the maximum number of steaks that can be cooked in 1 minute. If the remainder is bigger than 1(not equal, if equal you will get wrong answer ex: 7 and 4 yields answer 3 with actually is 4) then you write the number of sides divided by the maximum number(of sides) in the pan plus the extra that remains. Else you do the same without adding the extra. If k>n, then the maximum is 2 minutes(1 minute for each side) because all steaks fit in the pan. It's a simple and quick solution. Some examples: 1. 4 steaks and maximum 3 in a pan. You have 8 sides and a maximum of 3 in a pan. 8%3=1, that means that you have 2 sides extra. Answer is 8/3 + 1 =3 2. 7 steaks and maximum 4 in a pan. You have 14 sides and maximum 4 in a pan. 14%4=2, that is why you need to put 2*n%k>=1 and not 2*n%n==1. The answer is 14%4 + 1 =3+1=4 I hope that it helped! Edited by moderator 21.07.2014 01:04 thanks. Edited by author 07.07.2014 18:01 |
в условии ошибка | Иван | 1820. Ural Steaks | 3 Jun 2015 02:21 | 5 |
если жарить 3 бифштекса на сковороде, где умещается всего 2, то потребуется не 3, а 4 минуты, поскольку последний бифштекс на 2 части не разделить и не положить на сковороду одновременно обоими сторонами хотя нет, в три минуты тоже можно пожарить и разрезать ничего не надо Edited by author 13.05.2014 01:30 Нумеруме бифштексы оригинально 1, 2 ,3. Жарим 1 и 2. Жарим вторую половину 1 и 3. Жарим вторые половины 2 и 3. Вуаля - вы программист! Так вот оказывается как котлеты надо жарить.... |
Why? | without | 1820. Ural Steaks | 11 May 2014 18:27 | 2 |
Why? without 9 May 2014 02:45 if n=1(k any) we need 2 minuten, but when n=2 , k=5 we need 1 minutes. Why??? this is bug, it is imposible. if i have n = 1 and k = 10000, i need two minutes |
Test 8 | Adil | 1820. Ural Steaks | 23 Jun 2014 18:37 | 5 |
And me too, please. Old 8th test passed correct but that give me a wrong answer error. #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; if (k>n) cout << 2; else { if (2*n%k>=1) cout << 2*n/k+1; else cout << 2*n/k; } return 0; } Check my post for explanation Hint: Think of all possible cases. Edited by author 18.06.2014 08:01 Edited by author 18.06.2014 08:01 |
How to solve this problem without sturctures | yutr777 | 1820. Ural Steaks | 24 Dec 2013 23:14 | 2 |
I have solved this problem using heap:) Please, give me advise, how to solve this problem without structures and etc. Oh my God.....i can't write 2*n / k + 1 (if 2*n%k==1) else 2*n / k Oh...I'm stupid deer |
WA8 | endtimes | 1820. Ural Steaks | 20 May 2014 22:40 | 4 |
WA8 endtimes 7 Dec 2013 19:18 Module Module1 Sub Main() Dim a() As String = Console.ReadLine.Split(" ") Dim n, k As Integer n = 2 * CInt(a(0)) k = CInt(a(1)) Dim rez As Integer = Math.Ceiling(n / k) Console.WriteLine(rez) End Sub End Module I got wrong answer for test#8 but my output is 2. What is wrong? Edited by author 12.05.2014 00:54 |
A mistake in the example. | asiorx22 | 1820. Ural Steaks | 10 Sep 2013 01:58 | 2 |
Just think about it. In the example there are three steaks, and only two can be cooked at the same time. It would take two minutes to cook both sides of the first pair and another two to prepare the last steak. In total it makes four. I'm just curious, did the author mistype or is there an actual mistake in the program. Sample is correct, find the mistake in your logic. |
test 30 | Alex | 1820. Ural Steaks | 1 Sep 2013 23:49 | 1 |
My solution failed in test 30. How I can find what is wrong? Help me please Edited by author 01.09.2013 23:49 |