Alice is bored out of her mind by her math classes. She craves for something much more exciting. That is why she invented a new type of numbers, the profacts. Alice calls a positive integer number a profact if it can be
expressed as a product of one or several factorials.

Just today Alice received n bills. She wonders whether the costs on the bills are profact numbers. But the numbers are too large, help Alice check this!

Input

The first line contains a single integer n, the number of bills (1 ≤ n ≤ 105). Each of the next n lines
contains a single integer ai, the cost on the i-th bill (1 ≤ ai ≤ 1018).

Output

Output n lines, on the i-th line output the answer for the number ai.
If the number ai is a profact, output "YES", otherwise output "NO".

Sample Input

Input
7
1
2
3
8
12
24
25
Output
YES
YES
NO
YES
YES
YES
NO

Hint

这题可以把所有的情况都列举出来然后放入set,然后判断在不在set里面就行了,这里为了爆long long,有一个技巧,判断t乘上k是不是大于10^18,可以用10^18除以t,然后看结果是不是小于k,如果小于,那么t*k>10^18

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
#define ll __int64
#define inf 0x7fffffff
#define maxn 1000000
set<ll>myset;
set<ll>::iterator it;
ll a[maxn];
ll b[30];
void getnum()
{
int i,j;
b[1]=1;
for(i=2;i<=19;i++){
b[i]=b[i-1]*i;
}
} void init()
{
myset.clear();
myset.insert(1);
getnum();
for(int i=2;i<=19;i++){
int tot=0;
for(it=myset.begin();it!=myset.end();it++){
tot++;
a[tot]=*it;
}
ll t;
for(int j=1;j<=tot;j++){
t=a[j];
while((1e18)/t>b[i] ){
myset.insert(t*b[i]);
t*=b[i];
}
}
} } int main()
{
int n,m,i,j;
init();
scanf("%d",&n);
ll num; int cnt=0; for(i=1;i<=n;i++){
scanf("%I64d",&num);
if(num==1){
printf("YES\n");continue;
}
it=myset.find(num);
//printf("--%d\n",*it);
if(it==myset.end())printf("NO\n");
else printf("YES\n");
}
return 0;
}

Gym 100796K Profact的更多相关文章

  1. ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力

     Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS     Memory Limit:65536KB     64bit IO Fo ...

  2. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  3. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  4. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  5. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  6. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  7. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

  8. Gym 101102D---Rectangles(单调栈)

    题目链接 http://codeforces.com/gym/101102/problem/D problem  description Given an R×C grid with each cel ...

  9. Gym 101102C---Bored Judge(区间最大值)

    题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...

随机推荐

  1. 【Java基础】枚举类与注解

    枚举类与注解 枚举类的使用 当需要定义一组常量时,强烈建议使用枚举类. 枚举类的理解:类的对象只有有限个,确定的. 若枚举只有一个对象, 则可以作为一种单例模式的实现方式. 枚举类的属性: 枚举类对象 ...

  2. centos 6.5 下安装RabbitMQ-3.7.28 二进制版本

    centos 6.5 下安装RabbitMQ-3.7.28 二进制版本 安装依赖: yum install -y ncurses-devel socat logrotatewxWidgets-deve ...

  3. 基于B/S架构的在线考试系统的设计与实现

    前言 这个是我的Web课程设计,用到的主要是JSP技术并使用了大量JSTL标签,所有代码已经上传到了我的Github仓库里,地址:https://github.com/quanbisen/online ...

  4. ES6 自定义一个实现了Iterator接口的对象

    参考资料 var obj = { data: [1,2,3,4,5], // 这里实际上就是去定义如何实现Iterator接口 [Symbol.iterator](){ const that = th ...

  5. Linux 文件查看相关的一些命令

    文件压缩解压命令 # 解压 xxx.xz 并删除 xz -d test.tar.xz # 打包成 xxx.tar , 语法: tar -cvf 最后包名.tar ./要打包文件 ./要打包的文件 ta ...

  6. 打包遇到错误Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test

    引自:https://blog.csdn.net/xiexiangyan/article/details/107936774 遇到的问题 有一个maven项目,我clone一下最新的代码.准备打包(m ...

  7. try-catch-finally中的4个大坑,不小心就栽进去了!

    在 Java 语言中 try-catch-finally 看似简单,一副人畜无害的样子,但想要真正的"掌控"它,却并不是一件容易的事.别的不说,咱就拿 fianlly 来说吧,别看 ...

  8. C#高级编程第11版 - 第七章 索引

    [1]7.1 相同类型的多个对象 1.假如你需要处理同一类型的多个对象,你可以使用集合或者数组. 2.如果你想使用不同类型的不同对象,你最好将它们组合成class.struct或者元组. [2]7.2 ...

  9. 记一次Nginx反向代理500的排查记录

    今天公司项目遇到一个奇怪的问题,记录一下. 注: 数据已经过脱敏处理,未暴露公司具体的IP等数据. TLDR; 项目简单介绍 用 Vue + ElementUI 实现的后台项目(以下简称:a-proj ...

  10. Salt (cryptography)

    Salt (cryptography) Here is an incomplete example of a salt value for storing passwords. This first ...