唐磊的个人博客

保研路—浙大计算机院机试-可怜的16分

回忆下。25号,在06级学姐王静帮忙下,租了留学生公寓一间房。计算机官网上说的是98单间,180标准间的,结果硬是只租到了标准间。泱泱就睡王静学姐寝室,我就只有……第二天就退房了,想着就算26号走不了,也自己找个去找下有没有便宜的。

 

26号早上,早起。打车到紫荆港校区,再找计算中心。中途没吃早饭,想着不行啊,待会上机做题目,没能量了可不行,悲剧的是,超时盘点,关门,找了好久,找到了个食堂,拿了个汉堡,加豆浆,赶紧找个相貌好点滴帮忙刷卡,我给钱。再然后,苦逼的3个小时机试。

8点40开始机试,有4个题目,满帆100分,据说是题目难度递增。我看了看第一题,我对自己也清楚,能做出一道题目肯定不错了,事实也证明如此,不过最后连第一题也没拿到满分20分,只得了16分。题目如下:

A. Reversible Primes (20)

A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a prime.

Now given any two positive integers N (< 105) and D (1 < D <= 10), you are supposed to tell if N is a reversible prime with radix D.

Input Specification:

The input file consists of several test cases. Each case occupies a line which contains two integers N and D. The input is finished by a negative N.

Output Specification:

For each test case, print in one line “Yes” if N is a reversible prime with radix D, or “No” if not.

Sample Input:

73 10
23 2
23 10
-2

Sample Output:

Yes
Yes
No

刚开始硬是没懂题目意思。73 10 成37 是素数,可以理解,23 2 YES?23逆序32明显合数啊。最后试了试,23先转成二进制,再二进制逆序,再转成10进制后逆序,是素数。好吧,最后就一直在那瞎编。想不通,为啥自己调瞎整了近2个小时,最后结果是16分。管不了那么多了,就当玩玩。后面两个题目一个是堆栈相关的排队算平均时间。还有一个算话费的,最后一个好像是树还是图相关的哦,直接没读题目了。

就这样,第一次机试,以拿到16分告终。做完后,旁边一哥们问做出来几道?答曰:一道。扬长而去。

tanglei wechat
欢迎扫描二维码关注我的微信公众号