I - Older Brother Gym - 101490I
题目链接:https://cn.vjudge.net/problem/Gym-101490I
题目大意:给你一个整数,问你这个整数能不能表示成一个素数的k次方?
具体思路:对于每一个数,我们先判断他是不是素数,如果是素数的话,就一定可以。其次,我们看一下当前的这个数能不能唯一的素因数分解。
PS:因为题目数据量是1e9,我们不可能跑一个1e9的素数筛,这样的话肯定会超时,对于每一个进来的数,我们先判断他是不是素数,如果是素数的话,输出yes。否则,就跑1e6之前的素数,看能不能分解就可以了。
AC代码:
#include <iostream>
#include<stack>
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<cstring>
using namespace std;
# define ll long long
const ll maxn = 1e6+;
int prime[maxn];
int vis[maxn];
int num=;
void prim()
{
for(ll i = ; i < maxn; i++)
{
if(!vis[i])
prime[++num] = i;
for(ll j = ; j<=num ; j++)
{
if(i*prime[j]>=maxn)
break;
vis[i*prime[j]] = true;
if(i % prime[j] == )
break;
}
}
}
bool judge(int t)
{
if(t<=)
return false;
for(int i=; i<=sqrt(t); i++)
{
if(t%i==)
{
return false;
}
}
return true;
}
int main()
{
prim();
ll n;
scanf("%lld",&n);
ll flag=;
if(n==)
printf("no\n");
else
{
ll tmp=n;
if(judge(tmp))
{
printf("yes\n");
}
else
{
int flag=;
for(int i=; i<=num; i++)
{
//cout<<i<<" "<<prim[i]<<endl;
if(n%prime[i]==)
{
while(n%prime[i]==)
n/=prime[i];
// cout<<n<<endl;
if(n==)
flag=;
break;
}
}
if(flag)
printf("no\n");
else
printf("yes\n");
}
}
return ;
}
I - Older Brother Gym - 101490I的更多相关文章
- Codeforces Gym 100531D Digits 暴力
Problem D. Digits 题目连接: http://codeforces.com/gym/100531/attachments Description Little Petya likes ...
- 周赛-Toy Cars 分类: 比赛 2015-08-08 15:41 5人阅读 评论(0) 收藏
Toy Cars time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- hnu Counting ones 统计1-n 二进制中1的个数
Counting ones Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KB Total submit users ...
- Codeforces Round #303 (Div. 2) A 水
A. Toy Cars time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- 越狱Season 1- Episode 16
Season 1, Episode 16 -Burrows:Don't be. It's not your fault. 不要,不是你的错 -Fernando: Know what I like? 知 ...
- From missionary to firebrand--Eisle Tu [20160102]
From missionary to firebrand 杜叶锡恩(1913年(癸丑年)-2015年(乙未年),英文名字Elsie Hume Elliot Tu,丈夫是教育家杜学魁.她是香港著名的 ...
- hbmy周赛1--D
D - Toy Cars Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submi ...
- Urozero Autumn 2016. BAPC 2016
A. Airport Logistics 根据光路最快原理以及斯涅尔定律,可以得到从定点$P$进入某条直线的最佳入射角. 求出每个端点到每条线段的最佳点,建图求最短路即可. 时间复杂度$O(n^2\l ...
- ACM ICPC 2017 Warmup Contest 9 I
I. Older Brother Your older brother is an amateur mathematician with lots of experience. However, hi ...
随机推荐
- MyBatis:传参
MyBatis从入门到放弃二:传参 前言 我们在mapper.xml写sql,如果都是一个参数,则直接配置parameterType,那实际业务开发过程中多个参数如何处理呢? 从MyBatis API ...
- Codeforces ECR47F Dominant Indices(线段树合并)
一个比较显然的做法:对每棵子树用线段树维护其中的深度,线段树合并即可. 本来想用这个题学一下dsu on tree,结果还是弃疗了. #include<iostream> #include ...
- windows下安装PyTorch0.4.0
PyTorch框架,据说2018.4.25刚刚上架windows,安个玩玩 我的环境: windows 10 anaconda虚拟环境python3.6 cuda9.1 cudnn7 pytorch ...
- 自学huawei之路-AC6005版本升级步骤
返回自学Huawei之路 自学huawei之路-AC6005版本升级步骤 本文主要采用WEB网管界面升级,方便快捷,推荐使用此方法. 一.升级前检查 1.1 原AC/AP设备版本确认 disp ...
- BZOJ3235 [Ahoi2013]好方的蛇 【单调栈 + dp】
题目链接 BZOJ3235 题解 求出每个点为顶点,分别求出左上,左下,右上,右下的矩形的个数\(g[i][j]\) 并预处理出\(f[i][j]\)表示点\((i,j)\)到四个角的矩形内合法矩形个 ...
- CPP--借助神器VS理解内存存储(含大小端对齐)
单位,补码之类的可以看这个:http://www.cnblogs.com/dotnetcrazy/p/8178175.html 先说说大小端对齐的事情,然后再看: 内存最小单位==>Byte,i ...
- HTML5小游戏-简单抽奖小游戏
换了新工作以后,专注前端开发,平常空闲时间也比较多,可以多钻研一下技术,写一下博客.最近在学习canvas,参考网上的slotmachine插件,用canvas实现了一个简单抽奖小游戏. ...
- C# 数组&集合&泛型集合
一.数组 必须规定类型,必须规定长度: 1.定义 int[ ] i = new int[5]; int[] j = new int[]{1,2,3,4,5}; 2.数组的遍历: Console.Wr ...
- 百度地图infoWindow圆角处理
最近的一个项目用到了百度地图API里边的infoWindow弹框,但是百度自带的infoWindow弹框是个直角的矩形框,显示过于难看,于是有了将该框改为圆角的想法,但是API本身不支持样式的设置,所 ...
- HashMap 与 ConcurrentHashMap 在初始化不同大小容量时,实际分配的空间情况
HashMap.java int capacity = 1; int initialCapacitys[] = {1,2,3,4,5,6,7,8,9,10,11,13,15,16,17,2 ...