## Search found 28 matches

Wed Feb 12, 2003 9:40 pm
Forum: Volume 104 (10400-10499)
Topic: 10449 - Traffic
Replies: 58
Views: 21978
to dynamic:
change

Code: Select all

``while(scanf("%d",&n)!=EOF)``
to

Code: Select all

``while(scanf("%d",&n)==1)``
or use cin ( while(cin>>n) )
I don't know the source of this bug. I also had it when I rewrote my solution after contest.
Tue Feb 11, 2003 7:37 pm
Forum: Volume 104 (10400-10499)
Topic: 10449 - Traffic
Replies: 58
Views: 21978
During contest I used exactly the same method. But at first I forgot that if the number of destination point is 1 then answer always should be "?" (because cost of going from 1 to 1 is zero).
Sat Feb 08, 2003 7:37 pm
Forum: Other words
Topic: questions about Feb 8,2003 contest
Replies: 6
Views: 2154
For C and G you should use unsigned long long (__int64 for Visual C++ compiler) and out the answer as "%Lu".
Problem B:
angles can be more than 180 (so the max angle can be bigger than 180 too). At first I also check an area of the polygon and if it is negative I invert vertex order.
Wed Jan 15, 2003 1:44 pm
Forum: Volume 104 (10400-10499)
Topic: 10419 - Sum-up the Primes
Replies: 51
Views: 16970
I use dynamic programming to pregenerate results.
And my output is the same.
Tue Jan 14, 2003 11:16 pm
Forum: Volume 104 (10400-10499)
Topic: 10419 - Sum-up the Primes
Replies: 51
Views: 16970
It should mean that an answer 101+2 "smaller" than 2+101. As '+'<'0', you should sort lexicographically your primes up to 300 (101,103,107,109,11,113 ...) and when you search an answer, "lexicographically" smaller primes should be earlier and be prefered "lexicographically" bigger primes. But it see...
Mon Jan 06, 2003 10:45 pm
Forum: Volume 103 (10300-10399)
Topic: 10394 - Twin Primes
Replies: 101
Views: 32574
We can save memory and time if we don't take into account even numbers because all of them (except for 2) are not prime numbers. So we check primality only for odd numbers.
Wed Dec 18, 2002 9:35 pm
Forum: Volume 103 (10300-10399)
Topic: 10335 - Ray Inside a Polygon
Replies: 17
Views: 4042

### 10335

For those who've got accepted for this problem. Simulating reflections is not hard. But what is a trick with precision and rounding in this problem? When should I round current point coordinates to two digits? Only for comparing with vertexes and for output or in some other cases? Should I use usual...
Wed Dec 18, 2002 2:37 pm
Forum: Volume 103 (10300-10399)
Topic: 10322 - The Four in One Stadium
Replies: 7
Views: 2510
r1,r2,r3 - radiuses of the circles. r1>=r2>=r3.
if r3<r2*r1*(r1+r2)/(r2^2+r1^2+r2*r1) then the radius of the big circle is r1+r2 (it touches only two circles)

Your output for input is correct.
Tue Dec 03, 2002 10:22 pm
Forum: Volume 104 (10400-10499)
Topic: 10412 - Big Big Trees
Replies: 15
Views: 8931
It's very strange mistake. I (and I know at least one person more) did it too.
Maybe there is hypnotic text in the problem description that says to do this mistake.
Thu Nov 14, 2002 10:18 pm
Forum: Volume 103 (10300-10399)
Topic: 10394 - Twin Primes
Replies: 101
Views: 32574
Once again, why is it for(int j=i*2;j<MAX;j+=i) isprime[j]=0; in the original sieve algorithm? It is correct to write for(int j=i*i;j<MAX;j+=i) isprime[j]=0; because if x=a*b (a,b>=2), then x will be deleted (isprime[x]=0) when i=min(a,b). And it is possible to modify sieve algorithm so it will not ...
Tue Nov 12, 2002 11:46 am
Forum: Volume 103 (10300-10399)
Topic: 10394 - Twin Primes
Replies: 101
Views: 32574
There are many ways to get better time without using inline-assembler and hard optimization, but with using some better algorithm.
for(j=i+i+i+1;j<MAXSIEVEHALF;j+=i+i+1)
you can write
for(j=2*i*(i+1);j<MAXSIEVEHALF;j+=i+i+1)
and receive the same result but some faster.
Tue Nov 12, 2002 11:45 am
Forum: Volume 104 (10400-10499)
Topic: 10410 - Tree Reconstruction
Replies: 13
Views: 9155
It seems there is no test case such as: 5 5 4 3 2 1 5 4 3 2 1 because my program generates correct output: 1: 2: 1 3: 2 4: 3 5: 4 and also got AC. There are some more tests: 16 12 13 2 7 1 6 5 8 4 9 10 11 15 16 3 14 12 13 2 1 4 9 6 10 11 7 5 15 16 8 3 14 10 9 3 5 2 7 1 10 4 6 8 9 3 2 7 1 4 10 6 8 5 ...
Wed Jul 31, 2002 10:43 am
Forum: C++
Topic: How can I use C++ read()/write() functions?
Replies: 2
Views: 3249

### How can I use C++ read()/write() functions?

When I use read()/write() judge returns compile error (there is not <io.h>). Is there a way to use them? Or is there other low (fast) functions it is possible to use? For example, it seems _rtl_read() and _rtl_write() are the best to use in C++ Builder (the fastest i/o). They are better than read()/...