PAT甲级 1015 Reversible Primes (20分)
做好本题的首要是读懂题意,然后就是注意坑点,本题最后一个测试点即为坑点,因为int型最大的数转成2进制或者1进制肯定是会超越int的表示范围,故答案出错误。其余3个点为常规测试点。
附本人暴力代码,讲真不建议刷PAT直接对照着别人的代码敲一遍,那样提升会很小,自己实在做不出来再参考别人的,本人这题做了挺长时间的,但是还是自己AC了。100行左右的代码!
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
typedef long long LL;
using namespace std;
LL shuchange(LL n)
{
LL a[10000];
LL i=0,sum=0,weishu=0;
while(n)
{
a[i]=n%10;
n=n/10;
weishu++;
i++;
}
LL j=