Общий форумhi what is the total number of test cases for each problem ? Can someone provide more tests? I am using scanner.nextLine() to read line.charAt(pos) == '?' to compare in java and also Josephus allgorithm: jos[1] = 1; for (int i = 2; i < max_n; i++) { jos[i] = (jos[i - 1] + 1998) % i + 1; } My code is so small that I don't even know where is the bug Ok, the thing is I misunderstood the problem. You read ALL the input ignoring new lines, and then do the 'process'. I was reading line by line and doing 'process' for each line. Hope it will help the others. I'm wondering if anyone knows the 13th test... i think it's some kind of special case. 3 1 1 2 NO 3 1 2 3 Yes 2 1 2 NO These are 3 test i suppose cause, it doesn't specificate that we have multiple test cases in one input. Am I right? No, you are not right. There is just one test case in every input, multiple tests were written just for you. Test: 7 1 1 1 1 1 1 2 YES Test: 4 1 1 2 2 Ans: Yes Edited by author 11.11.2013 15:19 4 1 1 2 2 Yes cause: 1122 1212 1221 2121 2211 2112 Edited by author 16.12.2013 23:57 i thinks these tests are not suitable for 13th s. 'casue i passed these ,but get 13th wrong. Two-Eight-Nine.Thanks...!!! #include <stdio.h> #include <math.h> int main(){ double num1,num2,num3,num4; scanf("%lf %lf %lf %lf",&num1,&num2,&num3,&num4); printf("%.4lf\n%.4lf\n%.4lf\n%.4lf",sqrt(num4),sqrt(num3),sqrt(num2),sqrt(num1)); return 0; } why is it wrong? I think it's not necessarily exactly 4 numbers. Judging from my result, I think there are many numbers in the test case. So you need a list or something to store the integers first then print the sqrt in reversed order. (also, the integer is very big, so int type might not work) check the cases when you shoot hail over fence's westmost edge. input: 6 10 2 2 2 0 10 1 output: NO 9 9 0 9 9 0 5 4 4 5 0 9 9 0 -5 4 -4 5 9 0 Here is my program var n,k,i,time:longint; begin readln(n,k); if k=1 then writeln(n-1) else begin i:=0;time:=0;n:=n-1; while n>0 do begin if i<k then i:=i+1; n:=n-i;time:=time+1; end; writeln(time); end; end. > Here is my program > var > n,k,i,time:longint; > > begin > readln(n,k); > if k=1 then writeln(n-1) > else > begin > i:=0;time:=0;n:=n-1; > while n>0 do > begin >(***) if i<k then i:=i+1; > n:=n-i;time:=time+1; > end; > writeln(time); > end; > end. Have a look at the iteraton..as I understand i is the number of used cables... But on each iteration you should not add only one cable (***) but as much as possible, I mean if you have used i cables by now, next time you could use 2*i cables, if you have so much, NOT i:=i+1! Sample input: 12 6 Sample output: 4 1 sec. 1-2 2 sec. 1-3, 2-4 3 sec. 1-5,2-6,3-7,4-8 4 sec. 1-9,2-10,3-11,4-12 Bye! and Have a luck :) only 4 cases Edited by author 05.12.2014 19:38 Edited by author 05.12.2014 19:39 found my mistake. sorry for this post. Edited by author 05.12.2014 22:16 Edited by author 05.12.2014 22:16 You will not solve this problem ((( Edited by author 05.12.2014 13:37 Edited by author 05.12.2014 13:37 if 2 - try 2 4 0 3 2 if 10-11 - just not use sort. especially bubble one))) I have 2 and this test works correct Edited by author 05.12.2014 13:00 Can't get it. What in this test case. P.S. finding bridges from e-maxx with deep of recursion. i had 9 wroung attempts, 10 was AC lol i tried BFS. but WA in test #1. Can anyone suggest some test cases? Thanks.. Don't output last CRLF. Bad cheker. #include<iostream> #include<algorithm> using namespace std; int main() { int i,n,a[155],k=0; cin>>n; for(i=0;i<n;i++) cin>>a[i]; sort(a,a+n+1); for(i=0;i<n;i++) if(a[i]==a[i+3]) k++; cout<<k; return 0; } 5 600 600 600 600 600 Thank you!!! #include<iostream> #include<algorithm> using namespace std; int main() { int i,n,a[155],k=0; cin>>n; for(i=0;i<n;i++) cin>>a[i]; sort(a,a+n+1); for(i=0;i<n;i++) if(a[i]==a[i+3]) k++; cout<<k; return 0; } look at my test .... use your program 10 600 600 600 600 600 600 600 600 600 600 I think your answer is 7... But true answer is 2! Edited by author 26.05.2013 09:50 Sorry, but true answer is 1, on my opinion Edited by author 04.12.2014 17:01 Edited by author 04.12.2014 17:02 5 600 600 600 600 600 what is the answer for this test? my programm writes 1 isn't it right?? I construct vertical blocks made of bricks. Now, blocks are of height 1,2,3,...n-1. Now, to make these many i need n*(n-1)/2 bricks. But, I have n bricks so I have to remove former minus latter number of bricks, which is n(n-3)/2. Now, the problem can be changed to number of ways of obtaining n(n-3)/2 from numbers 1,2,3,...n-1 while each number can be used only once. If you find the approach to be correct, please tell me how to obtain this number.(I am a newbie in coding..:)). Let me know please, why i should not think in this way - i have A ways to make n-1 strip sequences. If i will add red or white strip from the left side, i have A ways to make n strip sequences. R/W + [n-1.....] But in the same time i can add red or white strip from the right side, and so i'll have another A ways to make n strip sequences. [n-1....] + R/W So, now i have 2*A ways to make n strip sequences. What's wrong in this kind of argumentation ? Some ways may be counted twice, so the ways will be less than 2A |
|