294 - Divisors

All about problems in Volume 2. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

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

Re: 294 please help me

Post by brianfry713 » Tue Jul 17, 2012 12:32 am

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

Re: 294 please help me

Post by sophi » Thu Sep 27, 2012 6:17 pm

Please Help me providing Sample I/O. I'm getting WA but can't figure it out
Thanks.

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

Re: 294 please help me

Post by brianfry713 » Thu Sep 27, 2012 10:46 pm

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

User avatar
shipu_a
New poster
Posts: 23
Joined: Tue Oct 23, 2012 8:04 pm
Location: Dhaka,Bangladesh
Contact:

294 please help me

Post by shipu_a » Thu Mar 28, 2013 7:27 pm

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

Re: 294 please help me

Post by hello » Mon May 27, 2013 11:38 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

Re: 294 please help me

Post by brianfry713 » Wed May 29, 2013 12:04 am

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

Post by X123 » Tue Dec 03, 2013 7:00 pm

why WA? couldnt find out!!
:roll:

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

Post by brianfry713 » Tue Dec 03, 2013 11:37 pm

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

Post by X123 » Wed Dec 04, 2013 10:02 am

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

Post by brianfry713 » Thu Dec 05, 2013 12:41 am

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

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

Re: 294 please help me

Post by bobSHIH » Thu Feb 13, 2014 7:03 am

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

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

Re: 294 please help me

Post by brianfry713 » Thu Feb 13, 2014 11:30 pm

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

Re: 294 please help me

Post by bobSHIH » Sun Feb 16, 2014 1:44 pm

brianfry713 wrote:Try solving it without using floating point.
well
after reading u're advise
i got AC
thanks a lot reallyyyyyy

btw I wonder why floating point causes problems :o

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

Re: 294 please help me

Post by brianfry713 » Tue Feb 18, 2014 8:28 pm

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

Post by ssavi » Thu Dec 04, 2014 7:25 pm

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 . :(

Post Reply

Return to “Volume 2 (200-299)”