Show all threads Hide all threads Show all messages Hide all messages | PLEASE HELP ME ANYBODY (What is test #8 ???) | tarashi (Kutaisi SU3) | 1011. Conductors | 22 Sep 2008 12:22 | 2 | program Project1; {$APPTYPE CONSOLE} uses SysUtils; var a,b,c1,d1:Extended; i,c,d,z:integer; BEGIN readln (a,b); for i:=1 to 20000 do begin c1:=i*a/100; d1:=i*b/100; c:=trunc(c1); d:=trunc(d1); if abs(d-c)=1 then begin z:=i; if (c1-c=0) or (d1-d=0) then z:=z+1; writeln (z); break; end; end; END. | WA | Snetch | 1011. Conductors | 24 Aug 2008 22:47 | 3 | WA Snetch 22 Jul 2008 06:55 I tried all tests that I found on the discussion board, and several random tests. On all of them this prog works fine. But I am still getting WA1 when I send it in. var p1,q1:Real; p,q,p2,q2,x,ans:LongInt; begin Readln(p1); p:=round(p1*100); Readln(q1); q:=round(q1*100); ans:=0; repeat ans:=ans+1; p2:=ans*p; q2:=ans*q; x:=p2+10000-p2 mod 10000; until x<q2; Writeln(ans); end. If I change it like this (I suppose, if the precision is three digits, it would work), I get TLE1. var p1,q1:Extended; p,q,p2,q2,x,ans:QWord; begin Readln(p1); p:=round(p1*1000); Readln(q1); q:=round(q1*1000); ans:=0; repeat ans:=ans+1; p2:=ans*p; q2:=ans*q; x:=p2+1000000-p2 mod 1000000; until x<q2; Writeln(ans); end. I never got through the first test =( var p1,q1:Real; p,q,p2,q2,x,ans:LongInt; begin Readln(p1); Readln(q1); - This is your MISTAKE !!!! q:=round(q1*100); p:=round(p1*100); ans:=0; repeat ans:=ans+1; p2:=ans*p; q2:=ans*q; x:=p2+10000-p2 mod 10000; until x<q2; Writeln(ans); end. You mast change { Readln(p1); Readln(q1); } to { read(p1,q1) } !!!!!!!!!!!!
Edited by author 18.08.2008 16:04 Thank you, I got AC! Damn it, I wasted so much time on this problem! | how to see a test input? | dranka | 1011. Conductors | 12 Jun 2008 03:40 | 2 | how can i see the test case used in a problem? what is the p and q for test#14? u can use a assert statement and check it out | solve | gyz113 | 1011. Conductors | 3 May 2008 15:31 | 2 | solve gyz113 15 Feb 2008 16:23 var a:longint; p,q:extended; begin read(p,q); p:=p/100; q:=q/100; a:=-1; repeat inc(a); until (trunc(a*q-0.0000000000000001)-trunc(a*p+0.0000000000000001))>0; write(a); end. -_-! #include<iostream> using namespace std; int res(int a, int b) { for(int i=1; i<=10001; i++) { long long x=(i*a); long long y=(i*b); long long z=((long long)(y/10000))*10000; if((x<z)&&(z<y)) {return i;} } } int main() { double a,b; cin>>a>>b; int a1=(int)(100.0*a+0.5); int b1=(int)(100.0*b+0.5); cout<<res(a1,b1)<<endl; return 0; } | could u give me some test | beautiful | 1011. Conductors | 20 Apr 2008 15:28 | 1 | #include<iostream> #include<cmath> using namespace std; int main(){ double p,q,ans; long peo; while(cin>>p>>q){ p/=100,q/=100; peo=1; for(;;){ ans=floor(peo*q); if(ans>peo*p && ans<peo*q)break; peo++; } cout<<peo<<endl; } } this is my code it always get WA at #14 could u give me some test | Very very very easy! | ₦¯ίμ®@£ | 1011. Conductors | 11 Apr 2008 15:24 | 3 | I used real first time so I got WA#21, but when I used extended I got AC!. C++ sucks, Pascal forever! You need a few minutes in the quiteness to solve this very easy problem! Maybe it is not such easy like you said about your opinion on c++: MY advise to you-> Don't forget that at the 2008 acm contest solving problems on pascal will be terminated. Never forget the flexability of c++ | 21 | Mike | 1011. Conductors | 8 Dec 2007 18:11 | 4 | 21 Mike 28 Mar 2007 16:20 What can be wrong at 21 test?Using c++,double types and rounding with int(double k). Re: 21 Iskren Ivov Chernev 28 Sep 2007 01:49 round using (int)(x + 0.5) where x is double Re: 21 FC BARCA 15 Nov 2007 19:10 What is wrong in the test #21.Anyone help me. Re: 21 Vladimir Alexanov Belgorod STU 8 Dec 2007 18:11 Do you know that real numbers cannnot be compared sush way: r1=r2. Insead it is necessaryto write: abs(r1-r2)<0.000001; | So easy..)No Extended and Longint))Some tips | maksay | 1011. Conductors | 7 Dec 2007 23:17 | 1 | It's not vital here to use Extended or Longint...Some tips) 1). Maximum answer is not greater then 10000 2). You can calculate number of conductors (when you know total number of citizens) using Real - not Extended, Comp or sth. like that Edited by author 07.12.2007 23:18 | Good advice: don't use real variables, use extended or longint! | Punkrocker | 1011. Conductors | 13 Nov 2007 17:19 | 6 | I got "WA on test 3" nine times, when I stored P and Q as real variables. But when I only substituted "real" by "extended", I got AC. If you don't want to use such advanced methods, like extended type, you can store P*100 and Q*100 as longint. This method gets AC too. Edited by author 23.09.2004 01:04 I agree. My program used real variables at first got WA again and again at test 3. Try this test: 24.80 24.83 The right answer is 129 If you use real, the asnwer is 125 24.80 / 100 * 125 = 31.0000000000 24.83 / 100 * 125 = 31.0375000000 Good Luck! <...> well, you are rigth Edited by author 23.04.2006 00:12 Edited by author 21.02.2007 21:33 I agree! First, I always WA at text 14, but when I use "extended", I got AC. You don't need to use any real types in your programs! The problem can be easily solved with integer types! | More Than!!!OMG... | Neptun | 1011. Conductors | 26 Sep 2007 12:06 | 1 | "We know that there are MORE THAN P% conductors and LESS THAN Q% conductors" I didn't see this so I got WA and WA and WA again... | 15 lines AC | shiqicao | 1011. Conductors | 12 Jun 2007 20:00 | 7 | #include <iostream.h> void aaa(double p,double q,double m,double mp,int n) { int t=(int)(m/q)+1; if(p*t<mp){cout<<n+t;} else { aaa(p,q,1-q*t+m,1-p*t+mp,n+t);} } void main() { double 1p,q; cin>>p>>q; p/=100; q/=100; aaa(p,q,1,1,0); } Your program is wrong, though you got AC! When P=22.39, Q=22.5, your answer is 40, according to your program. But the correct answer is 49. Because 40*22.39%=8.956, and 40*22.5%=9. There is no such integer n, 8.956<n<9. 49*22.39%=10.9711,49*22.5%=11.025.See,10.9711<11<11.025 My program has only 15 lines, too. #include<iostream.h> #include<math.h> void main(){ double P,Q; cin>>P>>Q; int number=1,min=1,max=0; while(min>=max) { min=(int)(number*P*100)/10000+1; max=(int)(number*Q*100)/10000; if((int)(number*Q*100)%10000!=0)max++; number++; } cout<<(number-1)<<endl; } Edited by author 21.04.2004 00:58 14 lines #include <iostream> #include <cmath> using namespace std; int main() { double p,q; cin>>p>>q; p/=100.; q/=100.; long long n=1; while(ceil(n*q)-ceil(n*p) < 1) n++; cout<<n; return 0; } #include <iostream.h> int main() { double p,q; int x=1; cin>>p>>q; while(((int)(x*q/100)-(int)(x*p/100))!=1) { x++; if(((x*q/100)-(int)(x*q/100))==0||((x*p/100)-(int)(x*p/100))==0) x++; } cout<<x<<endl; return 0; } #include <iostream.h> void aaa(double p,double q,double m,double mp,int n) { int t=(int)(m/q)+1; if(p*t<mp){cout<<n+t;} else { aaa(p,q,1-q*t+m,1-p*t+mp,n+t);} } void main() { double 1p,q; cin>>p>>q; p/=100; q/=100; aaa(p,q,1,1,0); } Hey man, Check your program. Try to take p = 0,01;q=0,20 your program will give 500! 500*0,01/100=0,05 500*0,2/100=1 So, the right answer is 501! As said your program is wrong... and LAAAARGE)... and is void... #include <stdio.h> int main() { float ans=0, P, Q; scanf("%f%f",&P,&Q); for(;;){ float f1=ans*P/100.0f,f2=(ans++)*Q/100.0f,i=int(f2); if(i)if((i>f1)&&(i<f2)){printf("%.0f\n",--ans);return 0;} } } there is something wrong in test 5... #include <stdio.h> #include <math.h> int main(){double p,q;scanf("%lf%lf",&p,&q);int x=1,m=floor(p*100.0+0.5),n=floor(q*100.0+0.5);while( (m*x/10000+1) >= (n*x/10000+(n*x%10000?1:0)) )++x;printf("%d\n",x);return 0;} Just make a joke! | test 8 | LiuKe | 1011. Conductors | 12 Jun 2007 15:25 | 1 | test 8 LiuKe 12 Jun 2007 15:25 I got an 'wrong answer'!! why?? | I would like to ask what's the problem? | Laji | 1011. Conductors | 10 May 2007 11:45 | 6 | I am using Pascal and this is my last submitted program [code deleted] I am WONDERING what's wrong with it and I have gone MAD because I have submitted for tens of times........ When I use Longint to solve it I've got an "Time limit exceed" and when I use Extended to calculate it said "wrong answer" on test#1..I don't know why ?~! Edited by moderator 09.05.2007 16:04 Try to use longint without any extended. I mean, read extended, transform it to longint (but carefully) and run. yes I have tried but failed It said that TIME LIMIT EXCEEDED and I also tried round() and trunc() and I got the same answer! I am bored........ Anyone would help me? I will send him my source code.I am not sure whether I have missed something important. But I noticed that long ago that the maxium result should be 5001.Am I wrong? Now .... I want to argue for my program. When I copy a 'AC' script from one of the post above, yes, sure enough it got an 'AC' but the program is rather SLOW. I tested some datas, which were like 0.01and0.02,0.02and0.03,.....until 99.98and99.99, but the result of MY program had NO DIFFERENCES from the AC's. I DON'T KNOW WHY ~?! Am I missed some IMPORTANT extreme situation? Help me, please. | Can you give a some TESTS PLZ!!! | Pasky | 1011. Conductors | 27 Mar 2007 23:17 | 1 | | what's going on #21 | icylord | 1011. Conductors | 16 Mar 2007 17:35 | 1 | AC at last Edited by author 16.03.2007 18:09 | Why WA#5? | Abhay | 1011. Conductors | 25 Feb 2007 19:55 | 2 | The follwing is my pgm. Could some give a test case not satisfied here? #include<iostream.h> #include<math.h> int main() { float p,q,a,b; int x,a1,b1; cin>>p>>q; p/=100; q/=100; for(x=1;x<=10000;x++) { a=p*x; b=q*x; a1=a; b1=b; if((float)b1==b) b1++; if((float)a1==a) a1--; if(abs(b1-a1)==1)break; } cout<<x; return 0; } The dude, at me too the fifth test does not go, but if it is interesting to you here my idea and algorithm My solve #include <iostream> #include <cmath> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("1011.in","r",stdin); freopen("1011.out","w",stdout); #endif double p,q; cin>>p>>q; p/=100.; q/=100.; int n=1,fr=n*p,to=n*q; while(ceil(n*q)-ceil(n*p) < 1) n++; cout<<n; return 0; } | Why WA? | dimozzz | 1011. Conductors | 23 Feb 2007 02:29 | 2 | If I suppose, that inhabitance less than 5000, I get WA#3. If I suppose, that inhabitance less than 8000, I get AC. Why, I don't understand? Cause the answer for 99.98 99.99 is 5001 :) | =( | Vivit | 1011. Conductors | 6 Feb 2007 04:01 | 1 | =( Vivit 6 Feb 2007 04:01 I don't know Why WA in test#3? [code deleted] Edited by moderator 13.02.2007 20:54 | To admins | JIeHuH*CCCP | 1011. Conductors | 5 Dec 2006 21:22 | 7 | Dear admins, Please pay attention to my message. Problem 1011. Are you sure with the test 17. My solution with the formula a: =-1; repeat inc (a); until (trunc (a*q-0.00000001)-trunc (a*p))> 0; was WA at test #17, though I sure that it's true. After a chat reading I have corrected it a: =-1; repeat inc (a); until (trunc (a*q-0.0000000000000001)-trunc (a*p+0.0000000000000001))> 0; , and it was AC, though I am sure, that it's wrong in math. 1) ------|p*a|-(k)-------------|q*a|------------(k+1)------- p*a - [p*a] = 0.9999999999... {0. (9)} and [q*a-0] - [p*a] = 1 (> =1) 2) 0 = 0.000000000001 p*a + 0 - [p*a + 0] = 0 (become integer) and [q*a-0] - [p*a+0] = 0 PS: or it is just an Pascal accuracy error? Edited by author 15.11.2006 04:27 Try make solution that uses olny integers (except variables for reading input). So you will have no problems with precision. I got only WA's while using floating point ariphmetic (in C++ and Pascal), and AC while using integers. Edited by author 15.11.2006 11:45 So "a" is integer (you cannot use inc with real) "trunc (a*q-0.00000001)" and "trunc (a*p)" are int too You don't understand me. Use something like this for reading input: double p1, q1; int p, q; .............. scanf("%lf%lf", &p1, &q1); p = floor(p1*100+0.5); q = floor(q1*100+0.5); And in your solution don't use p1, q1, and any other floating point variables and operations at all. Edited by author 20.11.2006 17:26 p = floor(p1*100+0.5); q = floor(q1*100+0.5); why are you using +0.5 with p1 and q1??? IMHO it's not fare and it's false. Edited by author 21.11.2006 04:49You could also do the follow thing: int p, q; scanf("%d.%d", &p, &q); where p is the integer part of the number and q is the rational part of the number. (sorry for the bad english...) | Totaly Confised | Lomir | 1011. Conductors | 1 Dec 2006 03:23 | 1 | Stupid mistake. To other with WA3. Test number 3 is test there first encountered different number of people is equal to p or q. o the answer must be +1. Edited by author 16.01.2007 16:17 |
|
|