## Search found 15 matches

- Fri Sep 02, 2011 3:36 pm
- Forum: Volume 120 (12000-12099)
- Topic: 12005 - Find Solutions
- Replies:
**9** - Views:
**4736**

### Re: 12005 - Find Solutions

I solved it, no need to find solutions, just count them

- Tue Jun 07, 2011 7:54 am
- Forum: Volume 114 (11400-11499)
- Topic: 11408 - Count DePrimes
- Replies:
**12** - Views:
**5790**

### Re: 11408 - Count DePrimes

I got TLE because my factor funtion is too slow. Are there any fast factorization algorithms for this problem? :roll: :cry: long Sum(long n, long a[]) /* a[] stores primes from 2 to 2221 */ { long r = 0, i = 0; while(n > 1) { if(isPrime(n,a)) { r += n; break; } while(n%a[i]) i++; while(n%a[i] == 0) ...

- Tue Jun 07, 2011 7:51 am
- Forum: Volume 120 (12000-12099)
- Topic: 12005 - Find Solutions
- Replies:
**9** - Views:
**4736**

### 12005 - Find Solutions

I get TLE on this problem :oops:. #include<stdio.h> #include<math.h> main() { long long n, i, j, k, r, t; while(1) { scanf("%lld",&n); if(!n) break; k = 4*n-3; i = 3; j = 2*n; r = 1; t = sqrt(k); while(i <= t) { if(j%i == 0) { r++; // printf("%lld %lld\n",j/i,(i+1)/2); } i+=2; j++; } r*=2; if(r > 2 ...

- Sun May 01, 2011 10:30 pm
- Forum: C
- Topic: Fast I/O Using fread() & fwrite
- Replies:
**5** - Views:
**5510**

### Re: Fast I/O Using fread() & fwrite

I know how to use fread() but I don't know how to parse input efficiently (I use strtok() and atoi() to get input numbers). Would anyone please help me

- Sun May 01, 2011 9:51 pm
- Forum: Volume 119 (11900-11999)
- Topic: 11991 - Easy Problem from Rujia Liu?
- Replies:
**32** - Views:
**9335**

### Re: 11991 - Easy Problem from Rujia Liu?

@ Rujialiu

I found that using fread/fwrite can get I/O much faster but I don't know how to use them

BTW, this is a nice problem. I think it can't be solve without using suitable data structure

I found that using fread/fwrite can get I/O much faster but I don't know how to use them

BTW, this is a nice problem. I think it can't be solve without using suitable data structure

- Sun May 01, 2011 6:36 pm
- Forum: Volume 114 (11400-11499)
- Topic: 11462 - Age Sort
- Replies:
**49** - Views:
**18425**

### Re: 11462 - Ages Sort

I've the same question as gtcoder (post above)

- Sun May 01, 2011 4:28 pm
- Forum: Volume 119 (11900-11999)
- Topic: 11960 - Divisor Game
- Replies:
**19** - Views:
**5385**

### Re: 11960 Divisor Game Getting WA!!

here is my NOD funtion long NOD(long n, long a[]) { long r=1, i=0, j; while(n>1) { if(isprime(n)) //if n is a prime number { r*=2; break; } while(n%a[i]!=0) i++; j=0; while(n%a[i]==0) { n/=a[i]; j++; } r*=(j+1); } return r; } I store prime numbers from 2 to sqrt(n) in the array a[]. a[0]=2, a[1]=3, ...

- Sun May 01, 2011 3:08 pm
- Forum: Volume 119 (11900-11999)
- Topic: 11960 - Divisor Game
- Replies:
**19** - Views:
**5385**

### Re: 11960 Divisor Game Getting WA!!

after viewing Imti's code I fixed my output from O(n/2) to O(1) and got AC in 1.7 secs . Now I'm thinking another algo to decrease my running time .

- Sat Apr 30, 2011 8:09 pm
- Forum: Volume 119 (11900-11999)
- Topic: 11960 - Divisor Game
- Replies:
**19** - Views:
**5385**

### Re: 11960 Divisor Game Getting WA!!

hey Imti your algo is the same as mine. I remember it took nearly 2 seconds to precaculate all NOD of all number from 1 to 1e6, so you may not have enough time to output your result

- Thu Apr 28, 2011 6:18 pm
- Forum: Volume 119 (11900-11999)
- Topic: 11960 - Divisor Game
- Replies:
**19** - Views:
**5385**

### Re: 11960 Divisor Game Getting WA!!

This problem is pretty similar to problem 294 - Divisors. I tried to find NOD (number of divisors) of all number in a certain range or precaculate NOD of all number from 1 to 1000000 but got TLE. Is there any better method to solve this problem? Please help

- Tue Apr 26, 2011 3:08 pm
- Forum: Volume 119 (11900-11999)
- Topic: 11991 - Easy Problem from Rujia Liu?
- Replies:
**32** - Views:
**9335**

### 11991 - Easy Problem from Rujia Liu?

hello everyone, sorry for creating this thread if you think it's useless :D I had got TLE in this problems many times and after 6 tries I got AC in 0.104 sec using my struct :D . But I found some guys got AC in about 0.08 or even 0.03 ~ 0.05 :o . I tried coding like this and send to judge to find ou...

- Sun Apr 17, 2011 6:07 am
- Forum: Volume 119 (11900-11999)
- Topic: 11970 - Lucky Numbers
- Replies:
**7** - Views:
**3604**

### Re: 11970 - Lucky Numbers

I only need to find all divisor of input number n in the range [1,(int)sqrt(n)) and for each divisor I print the answer :D for example, there are 2 divisors of 16 in the range [1,4) so output 2 numbers :D Moreover, I didn't use long long and long double, long is enough :D and your code is much more ...

- Mon Apr 11, 2011 7:53 pm
- Forum: Volume 119 (11900-11999)
- Topic: 11965 - Extra Spaces
- Replies:
**31** - Views:
**7804**

### Re: 11965 - Extra Spaces

Thank you very much, I got A.Cyan yan wrote:first, you mustindeedCode: Select all

`scanf("%d",&k);getchar();`

second, the last character can be space. It's possibleCode: Select all

`scanf("%d\n",&k);`

anyway, I tried to use fflush(stdin) instead of getchar() but it didn't work

- Mon Apr 11, 2011 5:04 pm
- Forum: Volume 119 (11900-11999)
- Topic: 11965 - Extra Spaces
- Replies:
**31** - Views:
**7804**

### 11965 - Extra Spaces

I've got W.A on this problem no matter how I fixed my code . Please help me
always have problems with string processing...

Code: Select all

`remove after A.C :D`

- Sat Apr 09, 2011 9:27 pm
- Forum: Volume 119 (11900-11999)
- Topic: 11946 - Code Number
- Replies:
**49** - Views:
**9173**

### Re: 11946- Code Number

I also got W.A many times because I forgot to add \n in the line
n is number of test cases.

Also remember not to print a blank line in the last test case.

Hope this help

Code: Select all

`scanf("%d\n",&n);`

Also remember not to print a blank line in the last test case.

Hope this help