## 294 - Divisors

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Try the input little joey posted in this thread.
Check input and AC output for thousands of problems on uDebug!

sophi
New poster
Posts: 6
Joined: Tue Aug 14, 2012 6:00 pm

Thanks.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

You can generate your own at
http://www.uvatoolkit.com/problemssolve.php
Check input and AC output for thousands of problems on uDebug!

shipu_a
New poster
Posts: 23
Joined: Tue Oct 23, 2012 8:04 pm
Contact:

input

Code: Select all

``````5
1 0
1 1
2 2
3 3
12 18
``````
output

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

hello
New poster
Posts: 25
Joined: Sun Mar 10, 2013 7:29 pm

got RTE ....but don't know why.....

Code: Select all

``````Remove after AC
[code]``````
Last edited by hello on Wed Jun 05, 2013 3:36 pm, edited 2 times in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Try increasing the size of your status array by one.
Check input and AC output for thousands of problems on uDebug!

X123
New poster
Posts: 11
Joined: Fri Oct 04, 2013 1:28 am

### 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
Many of life’s failures are people who did not realize how close they were to success when they gave up.

brianfry713
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!

X123
New poster
Posts: 11
Joined: Fri Oct 04, 2013 1:28 am

### Re: 294 - Divisors WA!!!

brianfry713 wrote:Try running your code on the sample input
oh.i didnt notice it . but my compiler was always giving correct output for sample input while other compilers were not!

thanx a lot
Many of life’s failures are people who did not realize how close they were to success when they gave up.

brianfry713
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!

bobSHIH
New poster
Posts: 4
Joined: Thu Feb 13, 2014 6:58 am

hello everyone
is there someone could help me?
I have got over 10 WA
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.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Try solving it without using floating point.
Check input and AC output for thousands of problems on uDebug!

bobSHIH
New poster
Posts: 4
Joined: Thu Feb 13, 2014 6:58 am

brianfry713 wrote:Try solving it without using floating point.
well
i got AC
thanks a lot reallyyyyyy

btw I wonder why floating point causes problems

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Check input and AC output for thousands of problems on uDebug!

ssavi
New poster
Posts: 28
Joined: Thu Nov 20, 2014 9:57 pm

### 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 .