Singles’ Day


Time Limit: 2 Seconds Memory Limit: 65536 KB


Singles’ Day(or One’s Day), an unofficial holiday in China, is a pop culture entertaining holiday on November 11 for young Chinese to celebrate their bachelor life. With the meaning of single or bachelor of number ‘1’ and the huge population of young single man. This festival is very popular among young Chinese people. And many Young bachelors organize parties and Karaoke to meet new friends or to try their fortunes that day.

On Singles’ Day, a supermarket has a promotional activity. Each customer will get a ticket on which there are two integers b and N, representing an integer M that only contains N digits 1 using b as the radix. And if the number M is a prime number, you will get a gift from the supermarket.

Since there are so many customers, the supermarket manager needs your help.

Input

There are multiple test cases. Each line has two integers b and N indicating the integer M, which might be very large. (2 <= b <= 16, 1 <= N <= 16)

Output

If the customer can get a gift, output “YES”, otherwise “NO”.

Sample Input

3 3

2 4

2 1

10 2

Sample Output

YES

NO

NO

YES

Hint

For the first sample, b=3, N=3, so M=(111)3, which is 13 in decimal. And since 13 is a prime number, the customer can get a gift, you should output “YES” on a line.

题意很简单,就是求长度为n的b进制数在每一位都是1的情况下,是不是素数

#include <stdio.h>
#include<math.h>
int su(long long x);
int main()
{
long long s,p;
int n,m,i,j;
while(~scanf("%d%d",&n,&m))
{
s=0;
while(m--)
{
s=s+pow(n,m);
}
if(su(s)==1)
{printf("YES\n");}
else
{printf("NO\n");}
}
return 0;
}
int su(long long x)
{
long long i;
if(x<2)return 0;
for(i=2;i*i<=x;i++)
{
if(x%i==0)
return 0;
}
return 1;
}

ZOJ Problem Set - 3758 素数的更多相关文章

  1. ZOJ Problem Set - 1394 Polar Explorer

    这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...

  2. ZOJ Problem Set - 1025解题报告

    ZOJ Problem Set - 1025 题目分类:基础题 原题地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=10 ...

  3. ZOJ Problem Set - 3829Known Notation(贪心)

    ZOJ Problem Set - 3829Known Notation(贪心) 题目链接 题目大意:给你一个后缀表达式(仅仅有数字和符号),可是这个后缀表达式的空格不幸丢失,如今给你一个这种后缀表达 ...

  4. ZOJ Problem Set - 2563 Long Dominoes 【如压力dp】

    称号:ZOJ Problem Set - 2563 Long Dominoes 题意:给出1*3的小矩形.求覆盖m*n的矩阵的最多的不同的方法数? 分析:有一道题目是1 * 2的.比較火.链接:这里 ...

  5. ZOJ Problem Set - 3593 拓展欧几里得 数学

    ZOJ Problem Set - 3593 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3593 One Person ...

  6. ZOJ Problem Set - 2297 Survival 【状压dp】

    题目:ZOJ Problem Set - 2297 Survival 题意:给出一些怪,有两个值,打他花费的血和能够添加的血,然后有一个boss,必须把小怪全部都打死之后才干打boss,血量小于0会死 ...

  7. ZOJ Problem Set - 3820 Building Fire Stations 【树的直径 + 操作 】

    题目:problemId=5374" target="_blank">ZOJ Problem Set - 3820 Building Fire Stations 题 ...

  8. ZOJ Problem Set - 3229 Shoot the Bullet 【有上下界网络流+流量输出】

    题目:problemId=3442" target="_blank">ZOJ Problem Set - 3229 Shoot the Bullet 分类:有源有汇 ...

  9. ZOJ Problem Set - 3822Domination(DP)

    ZOJ Problem Set - 3822Domination(DP) problemCode=3822">题目链接 题目大意: 给你一个n * m的棋盘,每天都在棋盘上面放一颗棋子 ...

随机推荐

  1. html语言中的meta元素

    1.定义语言  格式:〈meta http-equiv=″Content-Type″ content=″text/html; charset=gb2312″〉  这是META最常见的用法,在制作网页时 ...

  2. ASP.NET MVC学习系列 WebAPI初探

    转自http://www.cnblogs.com/babycool/p/3922738.html 一.无参数Get请求 一般的get请求我们可以使用jquery提供的$.get() 或者$.ajax( ...

  3. [序列化] SerializeHelper--序列化操作帮助类 (转载)

    点击下载 SerializeHelper.zip 这个类是关于加密,解密的操作,文件的一些高级操作1.XML序列化2.Json序列化3.SoapFormatter序列化4.BinaryFormatte ...

  4. Windows环境下使用cygwin ndk_r9c编译x264

     一.废话 最近学习,第一步就是编译.我们需要编译FFmpag,x264,fdk_aac,下面是x264,网上说的很多都是几百年前的,我亲测完美可用 还是那句话 我能力有限,但是我希望我写的东西能够让 ...

  5. Update Statistics用法

    Update Statistics语句的作用将创建的数据库表的有关统计信息更新到系统 sysmater的相关表中,以便查询优化器选择最佳的执行路径,当sysmaster库中没有相应的统计信息,或者统计 ...

  6. WPF 窗体中的 Canvas 限定范围拖动 鼠标滚轴改变大小

    xaml代码: <Canvas Name="movBg"> <Canvas.Background> <LinearGradientBrush EndP ...

  7. 将数字n转换为字符串并保存到s中

    将数字n转换为字符串并保存到s中 参考 C程序设计语言 #include <stdio.h> #include <string.h> //reverse函数: 倒置字符串s中各 ...

  8. UIActionViewController 详解 iOS8

    iOS8推出了几个新的“controller”,主要是把类似之前的UIAlertView变成了UIAlertController,这不经意的改变,貌似把我之前理解的“controller”一下子推翻了 ...

  9. 小记,取GB2312汉字的首字母【转】

    /// <summary> /// PY 的摘要说明. /// </summary> public class PY { // Fields private string m_ ...

  10. 运行从别处复制过来的linux可执行程序

    1, 首先ldd看看缺不缺so文件,如果不缺可忽略下面的文字,直接执行 2, 先看看缺的这些库在系统上有没有,这些库可通过安装开发包,第三方软件进行安装 3, 找到可能会包含这些库的可执行程序,ldd ...