It works on my laptop! I have Pascal ABC. var a,b,c:integer; begin readln(a,b); if a>b then c:=ceil(2*a/b) else c:=2; write(c); end. wrong answer test 13 why Because your solution are wrong. Cool answer. I'm sorry, but your English is bad. Solution can't be 'are'. using System; namespace ConsoleApplication5 { class Program { static void Main(string[] args) { string[] A = Console.ReadLine().Split(' '); float a = int.Parse(A[0]); float b = int.Parse(A[1]); if (a <= b) Console.WriteLine(2); else Console.WriteLine("{0:#}",a/b*2); } } }
your formula is not correct, think of more cases i am doing (n%k)+(n/k) after putting restriction on k(k<=1000) and n(n>=1). but my answer is said to be wrong.please help. import java.util.*; public class Bifshteks //zadacha -1820 { int n; int k; int clock; public static void main(String args[]) { Bifshteks b = new Bifshteks(); Scanner in = new Scanner(System.in); System.out.println("Skolko bifshteksov zakazat? - "); b.n = in.nextInt(); while(b.n > 1000 || b.n<0 ) {System.out.println("Skajite zanovo . Vam Skolko bifshteksov zakazat? - "); b.n = in.nextInt(); } System.out.println("Skolko bifshteksov mojet gotovitsia odnoremenno? - "); b.k = in.nextInt(); int y = b.n/b.k; int x = b.n-(y*b.k); if(x==0) y+=0; else y+=1; System.out.println("Vaw zakaz budet gotov cherez "+y*2+" minut."); } } Обратите внимание на постановку задачи: "В единственной строке через пробел записаны целые числа n и k (1 ≤ n, k ≤ 1000)." В Вашем случае одновременно 2 целых числа ввести нельзя. using System; namespace console_aplication54 { internal class Program { private static void Main(string[] args) { string[] nm = Console.ReadLine().Split(' '); if (int.Parse(nm[0]) >= 1 && int.Parse(nm[1]) <= 1000) { double x,y; x = double.Parse(nm[0]); y = double.Parse(nm[1]); Console.Write(Convert.ToInt32(Math.Ceiling(x*2)/y)); } } } } #include <iostream> using namespace std; int main() { int a,b,i=0,x=0,y=0; cin>>a>>b;
while(x+b<=a) { x=x+b; i++; } y=a-x; if(y>0) { i++; } while((y+b)<a) { y=y+b; i++; } i++;
cout<<i;
return 0; } Пример исходные данные результат 3 2 3 ||| - 3 бифштекса, 2 на одной сковороде || - 2 минуты | - 2 минуты итого 4 минуты, а не 3 Please read down the forum.. 12 23 13 их можно недожареные убирать потом опять ложить чтобы всегда на сковороде лежало з штуки! Подумай над этим Как? Если количество месть на сковороде 2 как ты туда одновременно положишь 3? вы че считать не умеете? how u can put third Steak if you can put only 2? Where is the Logic? А все я понял! Но все равно ты не правильно объясняешь!) А другим объяснить видимо нельзя,спасибо. Первая минута: 1 сторона 1-ого Б. , 1 сторона 2-ого Б. Вторая минута: 2 сторона 1-ого Б. , 1 сторона 3-ого Б.(первый готов) Третья минута: 2 сторона 2-ого Б. , 2 сторона 3-ого Б.(второй и третий готов) my program work. but timus don't accept answer. var n,k,m:word; begin read(n,k); if 2*n mod k=0 then m:=2*n div k else m:=(2*n div k)+1; write(m); end. K can be greater than N why is this take wrong answer? var n,k,m:word; begin read(n,k); if n>k then if 2*n mod k=0 then m:=2*n div k else m:=(2*n div k)+1; if n<= k then m:=2*n; write(m); end. When k >= n then we can cook all of them in two minutes (first minute one side, second minute second side) not in 2*n minutes. Edited by author 23.09.2011 20:06 Thank you!!!! I did it!!! why if 2n div k <> 0 you add 1? I donno how to make it work somebody give me hint There is my code on C. All test I found are passed. For example: hot (3,2) == 3); hot (3,10) == 2); hot (1,5) == 2); hot (5,3) == 4); hot (10,3) == 7); hot (7,3) == 5); hot (9,5) == 4); But server says that anyway test 1 - wrong. What is wrong? Please give me any test, which my program can't decide corectly. int hot (int n1, int k) { int n2, minutes = 0;
//Жарим первую сторону по максимальному числу бифштексов minutes += n1/k; //Пожаренные первые стороны становятся недожаренными вторыми n2 = minutes * k; //Ищем недожаренные первые стороны n1 -= minutes*k; //Докладываем на сковороду n2, если есть if (n2 > 0) { n2 -= (k-n1); if (n2<0) n2=0; } //Жарим остатки n1 и то, что доложили minutes++; //Пожаренное n1 переходит в n2 n2 += n1; n1 = 0; //Жарим вторую сторону minutes += (int) ceil((float)n2/k);
return minutes; } int main() { int n,k;
scanf("%d %d",&n, &k); printf("%d", hot(n,k)); return (EXIT_SUCCESS); } Edited by author 01.10.2012 09:26 Edited by author 09.11.2012 00:48 Edited by author 09.11.2012 00:48 #include <iostream> int main() { int n,k,a; std::cin>>n>>k; if ((2*n)%k==0) a=(2*n-(2*n)%k)/k; else a=(2*n-(2*n)%k)/k+1; std::cout<<a; return 0; } wrong answer po4emu ne pravilno, ved algoritm verni? Edited by author 25.10.2012 22:40 Edited by author 25.10.2012 22:40 if ((n%k)*2<=k) {answer=3;} Edited by author 21.10.2012 22:36 Edited by author 21.10.2012 22:39 The cook must cook the one steak during 2 minutes (each side during 1 minute). Right? In example n = 3, k = 2, then: * at first step he cook 2 stake during 2 minutes; * at second step he cook 1 stake during 2 minutes; Answer = 2 + 2 (minutes), but in example 3? If try to send solution based on above logic, checker answered with mistake. Probably checking occurs on this way (all test passed): answer == (k >= n) ? 2 : n * 2 / k + ((n*2 % k == 0) ? 0 : 1) but, more correctly (in my opinion) variant: answer == (k >= n) ? 2 : n * 2 / k + ((n % k == 0) ? 0 : 1) Your solution to n=3, k=2 is not optimal. Hint: examine different orderings, trying to keep the frying pan as full as possible all the time. In your solution, you have the frying pan half empty twice. what is in the test #7? here is my program var n,k:longint; begin readln(n,k); if (n<=k) then write(2*n) else if (n mod k=0) then write(trunc(2*n/k)) else write(trunc(1+(n-(n mod k))/k+((n-abs(k-(n mod k)))-((n-abs(k-(n mod k))) mod k))/k+((n-abs(k-(n mod k))) mod k)/k)); end. my sotution is WA#7 too. help me,pls what is in 13 test? Maybe something like that: n=5 k=3 The correct answer is 4 Exactly n == 7 && k == 3. True answer is 5! Thanks for a great test!!! Exactly n == 7 && k == 3. True answer is 5! WRONG true answer is 6!!!! I. 3 steak = 2 sec; II. 3 steak = 2 sec; III. 1 steak = 2 sec; 2+2+2=6. Edited by author 05.07.2012 20:16 Edited by author 05.07.2012 20:16 then 3 2 should be 4 . how they are 3 U r wrong: Sec status( 0-raw, 1-one side raw, 2-ready ) 1. 111 000 0 2. 222 000 0 3. 222 111 0 4. 222 221 1 5. 222 222 2 I've just found this mistake of mine :) U r wrong: Sec status( 0-raw, 1-one side raw, 2-ready ) 1. 111 000 0 2. 222 000 0 3. 222 111 0 4. 222 221 1 5. 222 222 2 I've just found this mistake of mine :) #include <iostream> #include <stdio.h> int main() { long n,k,t; scanf("%ld%ld",&n,&k); t=2*(n/k)+(n%k!=0)+((n%k>k/2.0)||(n<k)); printf("%ld\n",t); return 0; } Edited by author 05.05.2012 14:45 Edited by author 05.05.2012 14:45 but sometimes 0.031. Don't know why.. Edited by author 05.05.2012 15:05 result is n/k+1 + (n-1+n%k)/k to avoid WA8 check if k is greater than n. Can you explain it for me? I can't understand this formular.(sorry for my English) take me idea what is wrong: var a,b,c:integer; begin read(a,b); c:= (2*a) div b; if c=2*a/b then write(c)else write (c+1); end. p.s sorry for my english try test a=1, b - any number. you'll get answer c=1. |
|