Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
423 views
in Technique[技术] by (71.8m points)

c++ - Sample testcase for Interviewstreet: Equations

So there is a website named interviewstreet.com. Here we can find challenging programming problems. Unfortunately you have to be logged in to see the questions.

Here's a brief description of the problem I'm attempting to solve:

Find the no of positive integral solutions for the equations (1/x) + (1/y) = 1/N! (read 1 by n factorial) Print a single integer which is the no of positive integral solutions modulo 1000007.

For example, when N=3, (x,y) can be: (7,42), (9,18), (8,24), (12,12), (42,7), (18,9), (24,8). Or so I thought.

Help me please, especially you who have solved this problem. I have just coded for the problem Equations. There is something wrong with my algorithm, can I ask for output for the first 10 integers? i.e. N=2, N=3, N=4 ... N=10 so that I can find out the flaw in my algorithm. Thanks :)

EDIT: Oh, please don't post solution code as it will ruin the fun for me and for people trying to solve this :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

My solutions was accepted by interview street. Firstly, my solutions wasn't accepted, but after saw @Reinardus Surya Pradhit post, i realized, if pair (x, y) will be count twice, so i change it a litter bit and got success I will not post my solution here, but i can tell you the test case for all variable from N = 3 -> N = 10 Here the result

N=3: 9
N=4: 21
N=5: 63 
N=6: 135
N=7: 405
N=8: 675
N=9: 1215
N=10: 2295

My hint is: try to express N! in primes from like p1^q1 * p2^q2 * ... * pn^qn


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...