Search found 67 matches

by Ryan Pai
Wed Jul 04, 2007 12:03 pm
Forum: Volume 7 (700-799)
Topic: 766 - Sum of powers
Replies: 14
Views: 8997

It looks like you're printing extra spaces at the end of some lines. You probably don't want to do that.
by Ryan Pai
Mon Jul 02, 2007 3:32 am
Forum: Volume 1 (100-199)
Topic: 196 - Spreadsheet
Replies: 42
Views: 15624

I keep getting a presentation error on this problem, and it doesn't really describe what the format of the output should be. For those of you in a similar situation, there shouldn't be any blank lines between output cases.
by Ryan Pai
Fri Jun 02, 2006 4:52 pm
Forum: Volume 7 (700-799)
Topic: 734 - The Programmer's Hex
Replies: 8
Views: 4467

If you look at hex F in the example, it only has two valid rotations, so you shouldn't try all six for it.

Also, think about which hex you want to put down first.
by Ryan Pai
Sun Mar 26, 2006 6:53 am
Forum: Volume 2 (200-299)
Topic: 288 - Arithmetic Operations With Large Integers
Replies: 14
Views: 7698

So I keep getting WA. I implemented, but didn't post, a class Z which is meant to be an arbitrary precision integer class (it is meant to act like int, overloaded operaters etc.). I'm pretty sure the +,* and - work with the Z class, since I've used it on other problems. ** also seems to work (I test...
by Ryan Pai
Thu Mar 16, 2006 10:51 am
Forum: C++
Topic: STL or C style?
Replies: 5
Views: 9154

Another thing about the STL is that if used properly it can be faster than C code. Consider the qsort() function. It takes a function pointer as a parameter and uses that to compare two items. std::sort() does the comparision through a function object. A smart compiler could maybe inline the functio...
by Ryan Pai
Thu Mar 16, 2006 10:08 am
Forum: Volume 1 (100-199)
Topic: 194 - Triangle
Replies: 22
Views: 6984

Thanks Joey!

yeah, my problem was I was returning 2 instead of 1 from ssa (I had refactored my code like 7 different times, and forgot to change a constant).

(with the includes, I just didn't paste all my code).
by Ryan Pai
Thu Mar 16, 2006 9:09 am
Forum: Volume 1 (100-199)
Topic: 194 - Triangle
Replies: 22
Views: 6984

Well, then I have no idea what my error is. Here's my convoluted code and reasoning about what it's supposed to do. Here's the general idea of my code: First I look for non-positive values, and if there are any, return "bad" which means to print invalid input. Then I check that the angles ...
by Ryan Pai
Thu Mar 16, 2006 2:37 am
Forum: Volume 1 (100-199)
Topic: 194 - Triangle
Replies: 22
Views: 6984

I don't get the second example. The information it gives is a = 62.72048064, alpha = 2.26853639, and beta = 0.56794657. so, I calculate (from the angles summing to pi) gamma = .30510969... Then I use c = a * sin(gamma)/sin(alpha) = 24.58722428... So when I print it out I get 24.587224, which differs...
by Ryan Pai
Wed Mar 15, 2006 2:26 am
Forum: Volume 1 (100-199)
Topic: 176 - City Navigation
Replies: 20
Views: 9886

I got AC, so I'd like to share what my program assumes: Basically, ignore houses and consider every driveway as distinct (even if they do go to the same house). I don't know if the same driveway can be both the source and destination, but I answer 0 in that case. I define "cul de sac" when...
by Ryan Pai
Tue Feb 21, 2006 3:17 am
Forum: Volume 1 (100-199)
Topic: 135 - No Rectangles
Replies: 24
Views: 9532

http://online-judge.uva.es/board/viewtopic.php?t=177
If you're still confused, I could try to explain it in more detail.
by Ryan Pai
Tue Jan 10, 2006 8:06 pm
Forum: C++
Topic: stdio or iostream??
Replies: 6
Views: 3354

As misof said, scanf/printf are significantly faster than cin/cout. I've been hit by this on quite a few problems (including one I recently solved that took me about 20 submits). Most of the problems that are really that critical on runtime are in the earlier volumes and I find in such cases that I ...
by Ryan Pai
Mon Jan 09, 2006 8:25 am
Forum: Volume 1 (100-199)
Topic: 163 - City Directions
Replies: 24
Views: 13382

Ok, I just got AC and I spent so much time on this problem that I would like to make clear what the rules are: First check if the turn makes sense at all (i.e. there is a road in the direction you want to turn). If not then obviously the turn is NOT valid. Next check if you are entering or exiting a...
by Ryan Pai
Sun Sep 18, 2005 5:29 pm
Forum: Volume 108 (10800-10899)
Topic: 10820 - Send a Table
Replies: 34
Views: 17853

The slow part is probably your factoring. If you are iterating up to the square root of i and using the totient function then I would think that would be fast enough.

You could always try to use a faster factoring method.
by Ryan Pai
Thu Jun 16, 2005 2:20 am
Forum: Volume 107 (10700-10799)
Topic: 10774 - Repeated Josephus
Replies: 31
Views: 11722

Well, I ran your code and mine on every input the diff said they were exactly the same (and my code got AC).

This is a really odd situation.
by Ryan Pai
Wed Jun 15, 2005 3:29 pm
Forum: Volume 107 (10700-10799)
Topic: 10774 - Repeated Josephus
Replies: 31
Views: 11722

I basically did this pair<int,int> yours(int n){ // I put the main part of your code here, but took out the scanf return make_pair(len,n); //and did this instead of printf } pair<int,int> mine(int n){ // my code here } int main(){ for(int i=1;i<N;i++) if(yours(i)!=mine(i)){ cout<<"Oh pants, we ...

Go to advanced search