Search found 15 matches

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

Re: 12005 - Find Solutions

I solved it, no need to find solutions, just count them :)
by iriz7482
Tue Jun 07, 2011 7:54 am
Forum: Volume 114 (11400-11499)
Topic: 11408 - Count DePrimes
Replies: 12
Views: 5668

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) ...
by iriz7482
Tue Jun 07, 2011 7:51 am
Forum: Volume 120 (12000-12099)
Topic: 12005 - Find Solutions
Replies: 9
Views: 4687

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 ...
by iriz7482
Sun May 01, 2011 10:30 pm
Forum: C
Topic: Fast I/O Using fread() & fwrite
Replies: 5
Views: 5461

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 :oops:
by iriz7482
Sun May 01, 2011 9:51 pm
Forum: Volume 119 (11900-11999)
Topic: 11991 - Easy Problem from Rujia Liu?
Replies: 32
Views: 8938

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 :oops:
BTW, this is a nice problem. I think it can't be solve without using suitable data structure :D
by iriz7482
Sun May 01, 2011 6:36 pm
Forum: Volume 114 (11400-11499)
Topic: 11462 - Age Sort
Replies: 49
Views: 18084

Re: 11462 - Ages Sort

I've the same question as gtcoder (post above) :oops:
by iriz7482
Sun May 01, 2011 4:28 pm
Forum: Volume 119 (11900-11999)
Topic: 11960 - Divisor Game
Replies: 19
Views: 5303

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, ...
by iriz7482
Sun May 01, 2011 3:08 pm
Forum: Volume 119 (11900-11999)
Topic: 11960 - Divisor Game
Replies: 19
Views: 5303

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 :lol: . Now I'm thinking another algo to decrease my running time :oops: .
by iriz7482
Sat Apr 30, 2011 8:09 pm
Forum: Volume 119 (11900-11999)
Topic: 11960 - Divisor Game
Replies: 19
Views: 5303

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 :D
by iriz7482
Thu Apr 28, 2011 6:18 pm
Forum: Volume 119 (11900-11999)
Topic: 11960 - Divisor Game
Replies: 19
Views: 5303

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 :oops:
by iriz7482
Tue Apr 26, 2011 3:08 pm
Forum: Volume 119 (11900-11999)
Topic: 11991 - Easy Problem from Rujia Liu?
Replies: 32
Views: 8938

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...
by iriz7482
Sun Apr 17, 2011 6:07 am
Forum: Volume 119 (11900-11999)
Topic: 11970 - Lucky Numbers
Replies: 7
Views: 3541

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 ...
by iriz7482
Mon Apr 11, 2011 7:53 pm
Forum: Volume 119 (11900-11999)
Topic: 11965 - Extra Spaces
Replies: 31
Views: 7629

Re: 11965 - Extra Spaces

yan yan wrote:first, you must

Code: Select all

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

Code: Select all

scanf("%d\n",&k);
second, the last character can be space. It's possible :)
Thank you very much, I got A.C :D
anyway, I tried to use fflush(stdin) instead of getchar() but it didn't work :-?
by iriz7482
Mon Apr 11, 2011 5:04 pm
Forum: Volume 119 (11900-11999)
Topic: 11965 - Extra Spaces
Replies: 31
Views: 7629

11965 - Extra Spaces

I've got W.A on this problem no matter how I fixed my code :oops: . Please help me

Code: Select all

remove after A.C :D
always have problems with string processing... :-?
by iriz7482
Sat Apr 09, 2011 9:27 pm
Forum: Volume 119 (11900-11999)
Topic: 11946 - Code Number
Replies: 49
Views: 8889

Re: 11946- Code Number

I also got W.A many times because I forgot to add \n in the line

Code: Select all

scanf("%d\n",&n);
n is number of test cases.
Also remember not to print a blank line in the last test case.
Hope this help :D

Go to advanced search