I have some tests for my program: N K Result 3 2 4 4 3 5 4 2 8 5 2 12 5 3 8 5 4 6 6 2 18 6 3 12 6 4 8 6 5 7 7 2 24 7 3 16 7 4 12 7 5 9 7 6 8 8 2 32 8 3 21 8 4 16 8 5 12 Check my answers, please! Thank you. > I have some tests for my program: > N K Result > 3 2 4 > 4 3 5 > 4 2 8 > 5 2 12 > 5 3 8 > 5 4 6 > 6 2 18 > 6 3 12 > 6 4 8 > 6 5 7 > 7 2 24 > 7 3 16 > 7 4 12 > 7 5 9 > 7 6 8 > 8 2 32 > 8 3 21 > 8 4 16 > 8 5 12 > Check my answers, please! > Thank you. Some you tests are wrong... For example: 8 5 -> 11, 7 4 ->10, etc... Edited by author 15.08.2008 16:19 Edited by author 09.12.2012 18:28 Edited by author 09.12.2012 18:28 for 8 5 correct answer is 12 1 1 1 2 2 2 2 2 1 1 1 2 2 2 2 2 1 1 1 2 2 2 2 2 1 1 1 x x 3 3 3 1 1 1 x x 3 3 3 4 4 4 4 4 3 3 3 4 4 4 4 4 3 3 3 4 4 4 4 4 3 3 3 Thanks for tests! It helped me got AC. Just use diagonal painting: 1 2 3 ... k ... (total n times) 2 3 4 ... 1 ... (total n times) . . . ... . ... (total n times) Calculate, how many 1,2, ... k in this table. Answer will be minimal of them(every rectangle 1xK covers K different colors). I don't no is this mathematically correct, but this solution got AC. Don't forget, that if N < K answer is 0. P.S. Sorry for bad English. > Just use diagonal painting: > 1 2 3 ... k ... (total n times) > 2 3 4 ... 1 ... (total n times) > . . . ... . ... (total n times) > Calculate, how many 1,2, ... k in this table. Answer will be minimal > of them(every rectangle 1xK covers K different colors). > I don't no is this mathematically correct, but this solution got AC. > Don't forget, that if N < K answer is 0. > P.S. Sorry for bad English. email me: caa@baga.ac.net.ru >>> vasilisk_voin@mailru.com Can anybody give me example for this table?Please... For example what table will be if n=5 k=3 ? if N=5 and K=3 the correct answer is 8 but not 7. To see the solution don't use the square (3,3) in the 5*5 grid Edited by author 13.11.2005 13:39 Edited by author 13.11.2005 13:39 Why such found minimal value really achivable in all cases? its because for each number in the table there you can put 1*K piece so that it won't intersect with others.And answer is minimum value because each piece lays on K diffirent numbers so you can't put more pieces that numimum value of 1...k PS. Thanks! It's really easy to solve with O(1) time with your tips! This is only your belive... Told property has only minimal number. THE PROOF 1) if you "stack" the coffins, you use up all of the graveyard, except for N%K square in the corder. 2) if you "spiral" the coffins, you leave N-2(N%K) square in the middle after the first spiral, N-4(N%K) square after the second spiral, until you use up all of the graveyard, except for (N-2(N%K))%K square in the middle. (N-2(N%K))%K = (-N)%K = K-N%K 3) if we use the better of the two strategies, we use up all of the graveyard, except for M=min(N%K, K-N%K) square. How many colors will it have? The first row will be colored 1..M, the second 2..M+1, the last M..2M-1 All K colors will be present iff 2M-1>=K 4) M=min(N%K, K-N%K) guarantees M<=K/2 Therefore, the remaining square will not have all K colors. This proves that using the better of the two strategies exhausts at least one of the K colors, QED. please tell your idea more in detail thanks, i got AC when i use your idea. but i dont why it's true? who's know?
>var n,k,ans1,ans2:longint; > >begin > read(n,k); > if n<k then write('0') else begin > ans1:=(n div k)*(n + n mod k); > ans2:=(n-k)*4; > if ans1>ans2 then write(ans1) else write(ans2); end; >end. My program is very short. My method is like yours and I can't find the bug in it. What was wrong with yours? For 8 3 answer is 21, not 20 Why are these(n div k)*n+(n div k)*(n mod k), n*n div k not right? Show me my mistake. Thanks a lot. Test it for: 5 3 the answer must be 8 but this formula gets 7 Test it for: 5 3 the answer must be 8 but this formula gets 7 can you explain why is it 8! You can place 8 coffins like this: 1 2 3 3 3 1 2 4 4 4 1 2 0 5 6 7 7 7 5 6 8 8 8 5 6 yeah)) thanks a lot! that was a fast response did you get AC on this problem? Yes, 8 years ago :) Edited by author 08.11.2011 03:23 I have another problem... What If the cemetery is m*n and coffin is k*l... What is the correct formula? The 1255 Problem I've done, but this I cann't do... Help me, I need it... I recive wrong answer on test 7,how can I test my program: 5 3==8,9 6==12! What is testing test number 7 ??? See below the question : "Please, can somebody give some tests with answers!" Please give me some unusual tests that you can think of.I really want see where is my mistake.I always got wa on 10#test. By the way, if you have some good methods that are easy to understand,please mail me at xjoxjoxjo@126.com. thanx. Pogalusta proverti 1 test. Pohoge on ne vernuy ili prishlite mne. Hi. Everything is OK, Taras... An interesting problem, isn't it? This problem is OK. If you want to test 1st test just write this simple programme: Var n,k : integer; Begin readln(N,K); writeln(N*N div K); End. It takes WA on test 7 :) Look at the function f(): #define SGN(X) (((X)>eps)?1:(((X)<-eps)?-1:0)) const double eps=1e-6; double sol(double k,double p){ ____double l,r,m; ____l=0; ____r=1e5; ____while(r-l>eps){ ________m=(l+r)/2; ________if(((k+m)/sqrt(m*m+1))<p) ____________r=m; ________else ____________l=m; ____} ____return m; } int f(double k,double p){ ____int n; ____double x,w; ____if(SGN(p-1)<=0) ________return 0; ____x=sol(k,p); ____w=(1+x*k)/sqrt(x*x+1); ____if(SGN(p-w)>=0){ ________n=floor((p-w)/sqrt(x*x+1)); ________return(1+(int)n); ____}else ________return 0; } My (like any other) AC program outputs "0" for test "99 100", but it's incorrect! Because we can place coffins near main diagonal. Let's denote AC-program output as INCORRECT(n,k). Then the correct answer will be max{INCORRECT(n,k), (n+(n%k))*(n/k)+f(k,n%k)} and for test "99 100" it will be "82", not "0". Examples: "5 6" --> "1" "7 8" --> "2" "11 12" --> "4" "9999 10000" --> "9855". You may cut out respective paper rectangles to check it manually :^). But (it's really fun!) there are no tests like this (i.e. in all cases INCORRECT(n,k) >= (n+(n%k))*(n/k)+f(k,n%k) ), and programs which output INCORRECT(n,k) got AC! Coffins must be parallel to cemetery borders. Problem statement was updated. Thank you. I think that coffins must be paralell to sides of graveyard. It is my solution. Why my idea is wrong? program Project1; var n,r,a,b,k,i:integer; begin readln(n,k); a:=n; b:=n; r:=(a div k)*b; a:=a mod k; r:=r+(b div k)*a; b:=b mod k; writeln(r); readln; end. P.S. Sorry for bad English. Test: 5 3 Your answer: 7 Right answer: 8 The right solution is bit more difficult than your. Good luck :) I don't understand. Coffins must be paralell to the sides of graveyard or not? Yes, paralell. Last test: 11134 22234 56#34 56777 56888 I solved it! If anyone is interested, could ask me for something or even see my solution...just mail me on /////// vladovasilev@abv.bg ////////// But my solution is not a constant...so if anyone knows some really nice solution, could you tell me it, please..I'd like to know it! > I solved it! > If anyone is interested, could ask me for something or even see my > solution...just mail me on > /////// > vladovasilev@abv.bg > ////////// > But my solution is not a constant...so if anyone knows some really > nice solution, could you tell me it, please..I'd like to know it! > > could you tell me how to do 1132 I think 1132 is so difficult for me,and my English is not very well...... and can you give me some explain and CAn you give me some test with 1070 As I think if n > k then the solution is (n*n - 1) div k and that's why the answer for 7 4 is 12 1 2 3 4 4 4 4 1 2 3 5 5 5 5 1 2 3 6 6 6 6 1 2 3 7 8 9 10 10 10 10 7 8 9 11 11 11 11 7 8 9 12 12 12 12 7 8 9 And when n < k then it's quite difficult => wait and bleed))) > As I think if n > k then the solution is (n*n - 1) div k and that's > why the answer for 7 4 is 12 > 1 2 3 4 4 4 4 > 1 2 3 5 5 5 5 > 1 2 3 6 6 6 6 > 1 2 3 7 8 9 > 10 10 10 10 7 8 9 > 11 11 11 11 7 8 9 > 12 12 12 12 7 8 9 > And when n < k then it's quite difficult => wait and bleed))) > > As I think if n > k then the solution is (n*n - 1) div k and that's > > why the answer for 7 4 is 12 > > 1 2 3 4 4 4 4 > > 1 2 3 5 5 5 5 > > 1 2 3 6 6 6 6 > > 1 2 3 7 8 9 > > 10 10 10 10 7 8 9 > > 11 11 11 11 7 8 9 > > 12 12 12 12 7 8 9 > > And when n < k then it's quite difficult => wait and bleed))) What about (2, 1) or (4, 2) ??? > > > As I think if n > k then the solution is (n*n - 1) div k and > that's > > > why the answer for 7 4 is 12 > > > 1 2 3 4 4 4 4 > > > 1 2 3 5 5 5 5 > > > 1 2 3 6 6 6 6 > > > 1 2 3 7 8 9 > > > 10 10 10 10 7 8 9 > > > 11 11 11 11 7 8 9 > > > 12 12 12 12 7 8 9 > > > And when n < k then it's quite difficult => wait and > bleed))) > What about (2, 1) or (4, 2) ??? Не ну это понятно что если n делится на k то ответ N*N div K- я просто не успел до конца набить а потом лень переделывать было)) It's a very interesting fact- the problem which is incorrect!!!!!! I've come across the solution(it is "accepted") where the aswer for 99 100 is 0- so i'd like to know how could it be- the diagonal of the square is 140 and you are trying to say we can't place even 1 rectangle => so my recomendation is to put the task correctly and chek really correct programs I'm looking forward to hearing from you) I agree with you a little because it wasn`t in problem but: it was so clear that problems wantes amount of ways to put 1x100 rectangle in 99x99 square how its border get PARALLEL to borders of square! nothing is about real number and coorinates of all points are integer... Aidin_n7@hotmail.com > I agree with you a little because it wasn`t in problem > but: > it was so clear that problems wantes amount of ways > to put 1x100 rectangle in 99x99 square how its border > get PARALLEL to borders of square! > nothing is about real number and coorinates of all > points are integer... > > Aidin_n7@hotmail.com Pleeeeeeese show me wherw it is written that its border must be PARALLEL to borders of square? >n k >answer >4515 4459 >4571 >2410 1023 >5548 >1411 766 >2580 >777 213 >2808 >4768 515 >44109 >1938 583 >6381 >2877 1201 >6704 >4093 1156 >14248 >3334 46 >241632 >3224 1219 >8373 >3254 2932 >3576 >401 147 >1083 >3636 1256 >10512 >2713 1415 >5192 >4668 2885 >7132 var N,K,Result:longint; begin Read(N,K); If N<K then Result:=0 Else Begin if N mod K=0 then Result:=(N*N) div K else Result:=(N*N-1) div k; end; Write(Result); end. > var N,K,Result:longint; > begin > Read(N,K); > If N<K then Result:=0 > Else > Begin > if N mod K=0 then Result:=(N*N) div K > else Result:=(N*N-1) div k; > > end; > Write(Result); > > end. > 5 3 3 3 3 2 1 4 4 4 2 1 5 6 X 2 1 5 6 7 7 7 5 6 8 8 8 aidin_n7@hotmail.com I have a question: What answer will be when K>N ?????? Help me, please ! > I have a question: > What answer will be when K>N ?????? > Help me, please ! if k>n then => 0 Var N, K : LongInt; begin Readln(N, K); WriteLn((Sqr(N)-Sqr(N Mod K)) Div K); end. isn`t answer of 7 4 ---> 10? aidin_n7@hotmail.com But it is wrong, indeed. Look at the following sample - 5 3 What is the answer? 7? No, it's 8! 1 1 1 2 3 4 4 4 2 3 5 6 * 2 3 5 6 7 7 7 5 6 8 8 8 Your formula don't work with 5 3. The answer is 8 like this: 1 1 1 3 4 but your program outputs (25 - 4) / 3 = 7 2 2 2 3 4 5 6 0 3 4 5 6 7 7 7 5 6 8 8 8 :) Can anybody help me- what is the answer for 99 100? > Can anybody help me- what is the answer for 99 100? 0 > > Can anybody help me- what is the answer for 99 100? > 0 >Да нифига не ноль- там тока диагональ примерно 140- хочешь сказать вдоль диагонали ни один прямоугольник не влезет а? Эт те не просто n*n - 1 div k I think that the problem is Pi... and the authors are pi... |
|