ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1011. Conductors

15 lines AC
Posted by shiqicao 20 Jul 2003 12:34
#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);
}
Re: 15 lines AC
Posted by KLW 21 Apr 2004 00:55
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
hey,brother,and c this AC one,maybe it can be compressed smaller...
Posted by young master 20 May 2004 00:01
#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;
}
shiqicao wrote 20 July 2003 12:34
#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);
}
Re: hey,brother,and c this AC one,maybe it can be compressed smaller...
Posted by Veniamin 22 Feb 2005 21:05
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!
Re: 15 lines AC
Posted by hardfire 25 Feb 2007 21:09
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;
}
Re: 15 lines AC
Posted by GrAd 30 Mar 2007 22:13
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...
3 lines AC
Posted by obtuseSword 12 Jun 2007 20:00
#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!