10699 - Count the factors

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

Moderator: Board moderators

Iffat
New poster
Posts: 25
Joined: Sat Jul 22, 2006 9:47 am

10699

i got run time error and following msg:

Your program has died with signal 8 (SIGFPE). Meaning:

Floating point exception

Code: Select all

``````#include<stdio.h>
#define MAX 1000050

int main()
{
long long  n,N,i,count,arr[MAX];
long  long t,s=0,k,j,q;
for(i=2;i*i<=1000000;i++)
{
t=1;
if(i==2){t=1;}
if((i%2)==0&&(i!=2))t=0;
else
{
for(j=3;j*j<=i;j+=2)
{
if((i%j)==0)t=0;
}
}
if(t==1)
{
s++;
arr[s]=i;

}
}
while(1)
{
scanf("%lld",&N);

if(N==0)break;
count=0;

for(q=1;arr[q]<N;q++)
{
if((N%arr[q])==0)count++;
}

printf("%lld : %lld\n",N,count);
}
return 0;
}``````
pzzz help me ...

Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: 10699

Iffat wrote:i got run time error and following msg:

Your program has died with signal 8 (SIGFPE). Meaning:

Floating point exception
You have foud primes only up to 1000 and not up to 10^6. Therefore, your array arr[] is not initialised after first few numbers.

Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: 10699

And btw, there is already a thread on this problem. If there is a thread on a particular problem, please, use it to post your question and do not create a new one. (see http://online-judge.uva.es/board/viewto ... ight=10699, http://online-judge.uva.es/board/viewto ... ight=10699 and http://online-judge.uva.es/board/viewto ... ight=10699)
forum 'Volume CVI' description wrote:All about problems in Volume CVI. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

tolgaulusoy
New poster
Posts: 1
Joined: Mon Jun 18, 2007 9:46 pm

10699 WA why

Does anybody know tricky testcase?

my testcase :
• 2
3
1000000
700001
6
1
10
500000
500001
123456
987651
11
999999
1000001
700001
999999
438444
78498
564231
0
and output :
• 2 : 1
3 : 1
1000000 : 2
700001 : 1
6 : 2
1 : 0
10 : 2
500000 : 2
500001 : 2
123456 : 3
987651 : 4
11 : 1
999999 : 5
700001 : 1
999999 : 5
438444 : 4
78498 : 4
564231 : 3
Last edited by tolgaulusoy on Sun Jul 29, 2007 7:49 pm, edited 5 times in total.

jainal cse du
New poster
Posts: 23
Joined: Thu Jul 27, 2006 2:43 pm
Location: University of Dhaka,Bangladesh

Code: Select all

``````please give me what is the different prime factors for following input:

289384
930887
692778
636916
747794
238336
885387
760493
516650
641422

``````

abdullah<cse du>
New poster
Posts: 39
Joined: Mon Dec 04, 2006 2:18 pm
Contact:
Jainal,

My accepted code gives the following output.

289384 : 3
930887 : 2
692778 : 5
636916 : 4
747794 : 3
238336 : 3
885387 : 2
760493 : 2
516650 : 3
641422 : 3

ABDULLAH.
We were in past, we are in past and we will go in past.

mohsincsedu
Learning poster
Posts: 63
Joined: Tue Sep 20, 2005 12:31 am
Location: Dhaka
Contact:

Thanks

I got ACC:)

Thanks to Martin Macko

The running time is 0.020 ...
how way i can improve my running time.....

Amra korbo joy akhdin............................

plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

Re: 10699 - Count the Factors

Consider these cases:

Code: Select all

``````2
4
18
95918
874211
942561
179550
529165
897750
840840
510510
0
``````

Code: Select all

``````2 : 1
4 : 1
18 : 2
95918 : 3
874211 : 2
942561 : 2
179550 : 5
529165 : 4
897750 : 5
840840 : 6
510510 : 7
``````
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

kier.guevara
New poster
Posts: 30
Joined: Thu Jul 19, 2012 11:24 pm

Re: 10699 - Count the Factors

Code: Select all

`````` got AC
``````
Just forgot to include the number itself to check as a prime

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 10699 - Count the Factors

plamplam wrote:Consider these cases:
Thanks for sharing.
Check input and AC output for over 7,500 problems on uDebug!

Tahanima
New poster
Posts: 8
Joined: Thu Dec 25, 2014 4:50 pm

Re: 10699 - Count the factors

Code: Select all

``````deleted the code as got AC
``````
Last edited by Tahanima on Sat Jan 17, 2015 11:19 am, edited 1 time in total.

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

Re: 10699 - Count the factors

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

Tahanima
New poster
Posts: 8
Joined: Thu Dec 25, 2014 4:50 pm

Re: 10699 - Count the factors

Got AC. Thank you.