Gym 100796K Profact
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
- 7
- 1
- 2
- 3
- 8
- 12
- 24
- 25
- 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的更多相关文章
- 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 ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
随机推荐
- 【JavaWeb】HTML&CSS 基础
HTML&CSS 基础 HTML 基础 HTML 标签 HTML标题:HTML 标题(Heading)是通过 h1 - h6 等标签进行定义的. HTML段落: HTML 段落是通过 p 标签 ...
- LeetCode485 最大连续1的个数
给定一个二进制数组, 计算其中最大连续1的个数. 示例 1: 输入: [1,1,0,1,1,1] 输出: 3 解释: 开头的两位和最后的三位都是连续1,所以最大连续1的个数是 3. 注意: 输入的数组 ...
- 【IMP】导出的时候显示ddl建表语句
导出数据后,在导入的时候想要显示出建表语句,可以用show=y这个选项来实现 imp test/test file=test.dmp ignore=y show=y fromuser=test1 to ...
- 【Oracle】查看表空间是否为自动扩展
查看指定的表空间是否为自动扩展 SQL> select file_name,autoextensible,increment_by from dba_data_files where tab ...
- CTFHub - Misc(流量分析)
数据库类流量: MySQL流量: 1.下载附件,是一个.pcap文件,用wireshark分析, 2.搜索ctfhub字段,即可得到flag, flag: ctfhub{mysql_is_S0_E4s ...
- (数据科学学习手札104)Python+Dash快速web应用开发——回调交互篇(上)
本文示例代码已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 这是我的系列教程Python+Dash快速web ...
- 5V充12.6V三节锂电池,5V升压12.6V的电路图
三串锂电池的充电电压是三串锂电池的最高电压值,就是12.6V了.5V充12.6V是5V给三串锂电池充电.如笔记本的USB口5V给三串锂电池充电,如5V的适配器或者手机充电器插上数据线给三串锂电池充电电 ...
- css-前端实现左中右三栏布局的常用方法:绝对定位,圣杯,双飞翼,flex,table-cell,网格布局等
1.前言 作为一个前端开发人员,工作学习中经常会遇到快速构建网页布局的情况,这篇我整理了一下我知道的一些方法.我也是第一次总结,包括圣杯布局,双飞翼布局,table-cell布局都是第一次听说,可能会 ...
- 夯实基础系列四:Linux 知识总结
前言 前三节内容传送门: 夯实基础系列一:Java 基础总结 夯实基础系列二:网络知识总结 夯实基础系列三:数据库知识总结 现在很多公司项目部署都使用的是 Linux 服务器,互联网公司更是如此.对于 ...
- C指针的这些使用技巧,掌握后立刻提升一个Level
这是道哥的第016篇原创 关注+星标公众号,不错过最新文章 目录 一.前言 二.八个示例 1. 开胃菜:修改主调函数中的数据 2. 在被调用函数中,分配系统资源 2.1 错误用法 2.2 正确用法 3 ...