10879 - Code Refactoring
Moderator: Board moderators
10879 - Code Refactoring
Can anyone tell me what factorizing scheme is used for the code,K?
Thanks in advance!
Thanks in advance!
- kbr_iut
- Experienced poster
- Posts: 103
- Joined: Tue Mar 25, 2008 11:00 pm
- Location: IUT-OIC, DHAKA, BANGLADESH
- Contact:
Re: 10879 - Code Refactoring
Dleted after AC
Last edited by kbr_iut on Wed Sep 10, 2008 10:44 am, edited 1 time in total.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
It is more tough to become a good person.
I am trying both...............................
- kbr_iut
- Experienced poster
- Posts: 103
- Joined: Tue Mar 25, 2008 11:00 pm
- Location: IUT-OIC, DHAKA, BANGLADESH
- Contact:
Re: 10879 - Code Refactoring(I am confused!!!!)
actually I misunderstud something....anyway AC now...again and again thanx....
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
It is more tough to become a good person.
I am trying both...............................
Re: 10879 - Code Refactoring why RTE
why i am getting RTE for this problem. I think this is a quite easy problem and all input is also giving the output
so where is the problem
please help somebody
here is the code:
pls pls 
so where is the problem
please help somebody
here is the code:
Code: Select all
Removed after AC

Last edited by abid_iut on Mon Dec 01, 2008 9:56 am, edited 1 time in total.
i love to wait... wait for better... and better will come...
http://akanoi.webs.com/
http://akanoi.webs.com/
-
- Learning poster
- Posts: 78
- Joined: Sun Nov 30, 2008 5:00 pm
- Location: IUT-OIC, Dhaka, Bangladesh
Re: 10879 - Code Refactoring
Hi Abid, in your code you have implemented sieve to check whether the input is a prime or not. Your sieve is upto 1,000,000. But please check the highest value for the input. When you are checking whether 10,000,000 is a prime or not..... what you think? Is'nt there a problem?
I have used your code and got accepted without doing any prime checking. Read the description of the problem carefully. There will be no prime numbers in the input. So..... You don't need to use sieve. Goodluck.
[By the way, you have used %lld for long data type which will be %ld...i think]
I have used your code and got accepted without doing any prime checking. Read the description of the problem carefully. There will be no prime numbers in the input. So..... You don't need to use sieve. Goodluck.
[By the way, you have used %lld for long data type which will be %ld...i think]
May be tomorrow is a better day............ 

Re: 10879 - Code Refactoring
Thankx Articuno
AC at last after 11 submission
thankx for ur help
AC at last after 11 submission

thankx for ur help
i love to wait... wait for better... and better will come...
http://akanoi.webs.com/
http://akanoi.webs.com/
-
- New poster
- Posts: 5
- Joined: Sun Dec 21, 2008 7:19 am
Runtime error 10879 - Code Refactoring
I am getting run time error for this problem. As the problem is related to find prime factors. I have build an array to hold prime numbers upto 5,000,001 thinking that it is sufficient. As i have tested various inputs while it pass. So can't understand what happens to the judge.
Anybody plz help. Here is my code:
Thanks in advance.
Anybody plz help. Here is my code:
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
//#include <time.h>
#include <vector>
#define N 5000002
using namespace std;
bool isprime[N];
typedef unsigned int uint;
/****Sieve Prime Generator****/
void fill(){
memset(isprime,1,sizeof(bool)*N);
for(uint i = 2; i < N; i++){
if(isprime[i])
for(uint k = (i<<1); k < N; k+=i)
isprime[k] = false;
}
}
int main(){
int i, n, Case=1, Number, count, temp;
scanf("%d",&n);
vector<int>NextPrime;
fill();
for (i = 2; i < N; i++){
if (isprime[i])
NextPrime.push_back(i);
}
vector<int>::iterator it;
while(n-- > 0){
count = 0;
scanf("%d",&Number);
printf("Case #%d: %d",Case++, Number);
temp = 0;
for (it = NextPrime.begin(); count < 2; it++){
if (!(Number%(*it)) && ((*it)*(*it)) != Number && temp != *it){
temp = Number/(*it);
printf(" = %d * %d",*it,temp);
count++;
}
}
printf("\n");
}
return 0;
}
Re: 10879 - Code Refactoring
NO need to produce primes.
This is an easy straight forward problem!!! just find the divisors using sqrt(n); where n is the input.
Be care full about this,
This is an easy straight forward problem!!! just find the divisors using sqrt(n); where n is the input.
Be care full about this,
K = A * B = C * D", where A, B, C and D are different positive integers larger than 1.
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
-
- New poster
- Posts: 28
- Joined: Mon Nov 15, 2004 5:00 pm
Re: 10879 - Code Refactoring
Hi guys,
This is my code. I've tested it with everything and it still fails. Is it possible for you guys to help? I'm very frustrated.
This is my code. I've tested it with everything and it still fails. Is it possible for you guys to help? I'm very frustrated.
Code: Select all
#include <cassert>
#include <cstdio>
#include <cmath>
using namespace std;
long long N, yy, ii, sq, K, countee, prev;
int main(void)
{
scanf("%lld\n", &N);
for (yy = 1; yy <= N; yy++)
//for (yy = 10000000; yy > 1; yy--)
{
scanf("%lld\n", &K);
//K = yy;
sq = (int)sqrt((long double)K);
printf("Case #%lld: %lld", yy, K);
countee = 0;
for (ii = 2; countee < 2 && ii < sq; ii++)
{
if (!(K % ii))
{
if (countee > 0 && (ii == prev))
continue;
printf(" = %lld * %lld", ii, (prev = K / ii));
countee++;
}
}
printf("\n");
}
return 0;
}
Re: 10879 - Code Refactoring
Hello .. I'm new here
i need a help
please !! I don't anderstand this problem any way
what is he want ?
thanks in advance

i need a help

please !! I don't anderstand this problem any way
what is he want ?
thanks in advance