ZSTU4274 约素 2017-03-22 17:11 66人阅读 评论(0) 收藏
4274: 约素
Description
判断一个正整数n的约数个数是否为p,其中p是素数。
Input
第一行给测试总数T(T <= 10000)。
接下来有T行,每行有两个数字n(1 <= n <= 1000000000)和p(2 < p <= 1000000000)。
Output
每组测试数据输出一行,如果n的约数个数是p,输出“YES”,否则输出“NO”。
Sample Input
5
64 7
911 233
1080 13
1024 11
20170211 1913
Sample Output
YES
NO
NO
YES
NO
——————————————————————————————————————————————
题目求给定n的约数的个数是否是p个,
暴力枚举到√n,判有多少个
#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
#define inf 0x3f3f3f3f int n,p; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&p);
int cnt=0;
for(int i=1; i<=sqrt(n); i++)
{ if(n%i==0)
{
if(i*i==n)
cnt++;
else
cnt+=2;
} }
if(cnt==p)
printf("YES\n");
else
printf("NO\n");
} return 0;
}
ZSTU4274 约素 2017-03-22 17:11 66人阅读 评论(0) 收藏的更多相关文章
- Codeforces777A Shell Game 2017-05-04 17:11 59人阅读 评论(0) 收藏
A. Shell Game time limit per test 0.5 seconds memory limit per test 256 megabytes input standard inp ...
- makefile基础实例讲解 分类: C/C++ 2015-03-16 10:11 66人阅读 评论(0) 收藏
一.makefile简介 定义:makefile定义了软件开发过程中,项目工程编译链.接接的方法和规则. 产生:由IDE自动生成或者开发者手动书写. 作用:Unix(MAC OS.Solars)和Li ...
- Codeforces816A Karen and Morning 2017-06-27 15:11 43人阅读 评论(0) 收藏
A. Karen and Morning time limit per test 2 seconds memory limit per test 512 megabytes input standar ...
- highgui.h备查 分类: C/C++ OpenCV 2014-11-08 18:11 292人阅读 评论(0) 收藏
/*M/////////////////////////////////////////////////////////////////////////////////////// // // IMP ...
- APP被苹果APPStore拒绝的各种原因 分类: ios相关 app相关 2015-06-25 17:27 200人阅读 评论(0) 收藏
APP被苹果APPStore拒绝的各种原因 1.程序有重大bug,程序不能启动,或者中途退出. 2.绕过苹果的付费渠道,我们之前游戏里的用兑换码兑换金币. 3.游戏里有实物奖励的话,一定要说清楚,奖励 ...
- Java中的日期操作 分类: B1_JAVA 2015-02-16 17:55 6014人阅读 评论(0) 收藏
在日志中常用的记录当前时间及程序运行时长的方法: public void inject(Path urlDir) throws Exception { SimpleDateFormat sdf = n ...
- Hdu 1429 胜利大逃亡(续) 分类: Brush Mode 2014-08-07 17:01 92人阅读 评论(0) 收藏
胜利大逃亡(续) Time Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Subm ...
- strace使用详解(转) 分类: shell ubuntu 2014-11-27 17:48 134人阅读 评论(0) 收藏
(一) strace 命令 用途:打印 STREAMS 跟踪消息. 语法:strace [ mid sid level ] ... 描述:没有参数的 strace 命令将所有的驱动程序和模块中的 ...
- Hdu2204 Eddy's爱好 2017-06-27 16:11 43人阅读 评论(0) 收藏
Eddy's爱好 Time Limit : 3000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Subm ...
随机推荐
- 在Linux中安装Oracle(较详细图解)
原创 http://www.cnblogs.com/nucdy/p/5603998.html 参考视屏:链接: https://pan.baidu.com/s/1kViEZQZ 密码: z7ha ( ...
- find 和 find_all 用法
soup = BeautifulSoup(requests.get(url).text, 'html.parser') soup.find('span', class_='item_hot_topic ...
- https请求失败,解决方法
把请求头中 Content-Type 属性去掉就可以了
- Java 字符串与对象进行比较 compareTo()
Java 手册 compareTo public int compareTo(String anotherString) 按字典顺序比较两个字符串.该比较基于字符串中各个字符的 Unicode 值.按 ...
- Bootstrap-CL:略缩图
ylbtech-Bootstrap-CL:略缩图 1.返回顶部 1. Bootstrap 缩略图 本章将讲解 Bootstrap 缩略图.大多数站点都需要在网格中布局图像.视频.文本等.Bootstr ...
- Eclipse中配置Maven build打包
Eclipse中配置Maven build打包 clean package
- jdbc练习demo
//连接云端服务器数据库工具类 public class TestJDBCUtil { public static String driver="com.mysql.jdbc.Driver& ...
- 跟我学算法-图像识别之图像分类(上)(基础神经网络, 卷积神经网络(CNN), AlexNet,NIN, VGG)
1.基础神经网络: 输入向量x,权重向量w, 偏置标量b, 激活函数sigmoid(增加非线性度) 优化手段: 梯度下降优化, BP向后传播(链式规则) 梯度下降优化: 1. 使用得目标函数是交叉熵 ...
- C#中使用DLL相关问题
一,C#调用 C/C++ 库函数 1,UNITY的C# VS工程常常打不开 属性页,右键工程无 [添加引用]项.原因是VS的自带工具[适用于UNITY的工具]导致的. 解决办法:VS-[工具]-[选项 ...
- vim调整粘贴时的文本缩进
解决办法: 1. 在拷贝前输入:set paste (这样的话,vim就不会启动自动缩进,而只是纯拷贝粘贴)2. 拷贝完成之后,输入:set nopaste (关闭paste) 在 Vim 中粘贴文本 ...