A1015 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 (<10

​5

​​) 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

单词

reversible

英 /rɪ'vɜːsɪb(ə)l/ 美 /rɪ'vɝsəbl/

n. 双面布料

adj. 可逆的;可撤消的;可反转的

Prime

n. (美、法)普赖姆(人名)

adj. (prime) 主要的,首要的;最好的;典型的;最适宜的;素数的

n. (prime) 盛年,鼎盛时期

v. (prime) 使准备好

题目分析

弄清楚题目意思(这是我目前最大的困难之一,英文真的很难搞啊),这道题目还是很简单的,一是如何判断一个数是不是质数,而是如何计算出根据机制翻转后的数,由于之前做过一道和进制有关的题,所以做起来感觉没什么困难,对了,1不是质数,>_<。

具体代码

#include<stdio.h>
#include<stdlib.h>

int is_prime(int n)
{
if(n==1)
return 0;
for (int i = 2; i

PTA A1015的更多相关文章

  1. 浙大PTA - - 堆中的路径

    题目链接:https://pta.patest.cn/pta/test/1342/exam/4/question/21731 本题即考察最小堆的基本操作: #include "iostrea ...

  2. 浙大PTA - - File Transfer

    题目链接:https://pta.patest.cn/pta/test/1342/exam/4/question/21732 #include "iostream" #includ ...

  3. ERROR<53761> - Plugins - conn=-1 op=-1 msgId=-1 - Connection Bind through PTA failed (91). Retrying...

    LDAP6.3在DSCC控制台启动实例完成,但是操作状态显示“意外错误”,查看日志如下: 04/May/2016:21:10:39 +0800] - Sun-Java(tm)-System-Direc ...

  4. PTA中提交Java程序的一些套路

    201708新版改版说明 PTA与2017年8月已升级成新版,域名改为https://pintia.cn/,官方建议使用Firefox与Chrome浏览器. 旧版 PTA 用户首次在新版系统登录时,请 ...

  5. PTA分享码-Java

    主要用于Java语法练习,非竞赛类题目.   1. Java入门          959dbf0b7729daa61d379ec95fb8ddb0   2. Java基本语法   23bd8870e ...

  6. C语言第一次实验报告————PTA实验1.2.3内容

    一.PTA实验作业 题目1.温度转换 本题要求编写程序,计算华氏温度100°F对应的摄氏温度.计算公式:C=5×(F−32)/9,式中:C表示摄氏温度,F表示华氏温度,输出数据要求为整型. 1.实验代 ...

  7. PTA题---求两个有序序列中位数所体现的思想。

    ---恢复内容开始--- 近日,在做PTA题目时,遇到了一个这样的题,困扰了很久.题目如下:已知有两个等长的非降序序列S1, S2, 设计函数求S1与S2并集的中位数.有序序列A​0​​,A​1​​, ...

  8. 第十四,十五周PTA作业

    1.第十四周part1 7-3 #include<stdio.h> int main() { int n; scanf("%d",&n); int a[n]; ...

  9. 第七周PTA作业

    第一题: #include<stdio.h> int main() { ; ; ){ sum=sum+i; i++; } printf("sum = %d\n",sum ...

随机推荐

  1. Sqlserver 游标的写法记录

    ---游标更新删除当前数据 ---1.声明游标 declare orderNum_03_cursor cursor scroll for select OrderId ,userId from big ...

  2. 类spring ioc 泛型保留

    类spring ioc 泛型保留 什么是泛型擦除 Java并不会传递泛型类,举个直观的栗子: @Component public class BaseProvider<T> { publi ...

  3. SpringMVC源码分析4:DispatcherServlet如何找到正确的Controller

    SpringMVC是目前主流的Web MVC框架之一.  我们使用浏览器通过地址 http://ip:port/contextPath/path进行访问,SpringMVC是如何得知用户到底是访问哪个 ...

  4. mybatis 中 useGeneratedKeys 和 keyProperty 含义

    MyBatis如何获取插入记录的自增长字段值: 第一步: 在Mybatis Mapper文件中添加属性“useGeneratedKeys”和“keyProperty”,其中keyProperty是Ja ...

  5. abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十五)

    core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+easyui+e ...

  6. [开源] FreeSql.AdminLTE 功能升级

    前言 FreeSql 发布至今已经有9个月,功能渐渐完善,自身的生态也逐步形成,早在几个月前写过一篇文章<ORM 开发环境之利器:MVC 中间件 FreeSql.AdminLTE>,您可以 ...

  7. zabbix设置钉钉报警

    1 添加机器人 在钉钉群里面添加一个机器人 会获取到一个URL: 'https://oapi.dingtalk.com/robot/send?access_token=62be1ea97b4653b8 ...

  8. dmg文件转iso格式

    1. 简介 dmg是MAC苹果机上的压缩镜像文件,相当于在Windows上常见的iso文件. dmg格式在苹果机上可以直接运行加载,在Windows平台上需要先转换为iso格式. 2. 转换工具 本文 ...

  9. ccpc网赛 hdu6703 array(权值线段树

    http://acm.hdu.edu.cn/showproblem.php?pid=6703 大意:给一个n个元素的数组,其中所有元素都是不重复的[1,n]. 两种操作: 将pos位置元素+1e7 查 ...

  10. lightoj 1382 - The Queue(树形dp)

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1382 题解:简单的树形dp加上组合数学. #include <iostr ...