294 - Divisors
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 294 please help me
Try the input little joey posted in this thread.
Check input and AC output for thousands of problems on uDebug!
Re: 294 please help me
Please Help me providing Sample I/O. I'm getting WA but can't figure it out
Thanks.
Thanks.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 294 please help me
You can generate your own at
http://www.uvatoolkit.com/problemssolve.php
http://www.uvatoolkit.com/problemssolve.php
Check input and AC output for thousands of problems on uDebug!
294 please help me
input
output
Code: Select all
5
1 0
1 1
2 2
3 3
12 18
Code: Select all
Between 1 and 1, 0 has a maximum of 2 divisors.
Between 1 and 1, 1 has a maximum of 1 divisors.
Between 2 and 2, 2 has a maximum of 2 divisors.
Between 3 and 3, 3 has a maximum of 2 divisors.
Between 12 and 18, 12 has a maximum of 6 divisors.
Nothing is imposible in the world.....And
Never Judge a Book by Its Cover.............
BUBT_Psycho
http://uhunt.felix-halim.net/id/168573
http://shipuahamed.blogspot.com
Never Judge a Book by Its Cover.............
BUBT_Psycho
http://uhunt.felix-halim.net/id/168573
http://shipuahamed.blogspot.com
Re: 294 please help me
Last edited by hello on Wed Jun 05, 2013 3:36 pm, edited 2 times in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 294 please help me
Try increasing the size of your status array by one.
Check input and AC output for thousands of problems on uDebug!
Re: 294 - Divisors WA!!!
why WA? couldnt find out!!
my code-
#include<stdio.h>
#include<math.h>
int divisor(int n)
{
int i,div;
double sqrtn;
if(n==1)
return 1;
else if(n==2)
return 2;
else{
div=2;
sqrtn=sqrt(n);
for(i=2;i<sqrtn;i++)
{
if(n%i==0)
{
div=div+2;
}
}
if(sqrtn*sqrtn==n)
div++;
return div;
}
}
int main() {
int n,div,max=0,U,L,T,a=1,maxn;
scanf("%d",&T);
while(a<=T)
{
scanf("%d %d",&L,&U);
max=0;
for(n=L;n<=U;n++)
{
div=divisor(n);
if(div>max){
maxn=n;
max=div;
}
}
printf("Between %d and %d, %d has a maximum of %d divisors.\n",L,U,maxn,max);
a++;
}
return 0;
}
help pls

my code-
#include<stdio.h>
#include<math.h>
int divisor(int n)
{
int i,div;
double sqrtn;
if(n==1)
return 1;
else if(n==2)
return 2;
else{
div=2;
sqrtn=sqrt(n);
for(i=2;i<sqrtn;i++)
{
if(n%i==0)
{
div=div+2;
}
}
if(sqrtn*sqrtn==n)
div++;
return div;
}
}
int main() {
int n,div,max=0,U,L,T,a=1,maxn;
scanf("%d",&T);
while(a<=T)
{
scanf("%d %d",&L,&U);
max=0;
for(n=L;n<=U;n++)
{
div=divisor(n);
if(div>max){
maxn=n;
max=div;
}
}
printf("Between %d and %d, %d has a maximum of %d divisors.\n",L,U,maxn,max);
a++;
}
return 0;
}
help pls

Many of life’s failures are people who did not realize how close they were to success when they gave up.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 294 - Divisors WA!!!
Try running your code on the sample input
Check input and AC output for thousands of problems on uDebug!
Re: 294 - Divisors WA!!!
oh.i didnt notice it . but my compiler was always giving correct output for sample input while other compilers were not!brianfry713 wrote:Try running your code on the sample input
thanx a lot

Many of life’s failures are people who did not realize how close they were to success when they gave up.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 294 - Divisors WA!!!
Check input and AC output for thousands of problems on uDebug!
Re: 294 please help me
hello everyone
is there someone could help me?
I have got over 10 WA
and i have read the other reply on board
but i still can't figure out why i got WA?
here is my code
is there someone could help me?
I have got over 10 WA
and i have read the other reply on board
but i still can't figure out why i got WA?
here is my code
Code: Select all
GOT AC
Last edited by bobSHIH on Sun Feb 16, 2014 1:42 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 294 please help me
Try solving it without using floating point.
Check input and AC output for thousands of problems on uDebug!
Re: 294 please help me
wellbrianfry713 wrote:Try solving it without using floating point.
after reading u're advise
i got AC
thanks a lot reallyyyyyy
btw I wonder why floating point causes problems

-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 294 please help me
Check input and AC output for thousands of problems on uDebug!
Re: 294 - Divisors
How Can I Optimize My Code ????? Please Someone help ..... v1n1t sir / Brainfry sir please ???
Code: Select all
#include<stdio.h>
int main()
{
long long int u, l, i, j, count, max, t, d;
scanf("%lld",&t);
while(t--)
{
max=0;
scanf("%lld %lld",&u, &l);
for(i=u;i<=l;i++)
{
count=0;
j=i;
while(j>=1)
{
if((i%j)==0)
count++;
j--;
}
if(count>max)
{
max=count;
d=i;
}
}
printf("Between %lld and %lld, %lld has a maximum of %lld divisors.\n",u, l, d, count);
}
return 0;
}
I know I am a Failure Guy . 
