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
  1. 7
  2. 1
  3. 2
  4. 3
  5. 8
  6. 12
  7. 24
  8. 25
Output
  1. YES
  2. YES
  3. NO
  4. YES
  5. YES
  6. YES
  7. NO

Hint

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

  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include<string.h>
  5. #include<math.h>
  6. #include<vector>
  7. #include<map>
  8. #include<set>
  9. #include<queue>
  10. #include<stack>
  11. #include<string>
  12. #include<algorithm>
  13. using namespace std;
  14. #define ll __int64
  15. #define inf 0x7fffffff
  16. #define maxn 1000000
  17. set<ll>myset;
  18. set<ll>::iterator it;
  19. ll a[maxn];
  20. ll b[30];
  21. void getnum()
  22. {
  23. int i,j;
  24. b[1]=1;
  25. for(i=2;i<=19;i++){
  26. b[i]=b[i-1]*i;
  27. }
  28. }
  29. void init()
  30. {
  31. myset.clear();
  32. myset.insert(1);
  33. getnum();
  34. for(int i=2;i<=19;i++){
  35. int tot=0;
  36. for(it=myset.begin();it!=myset.end();it++){
  37. tot++;
  38. a[tot]=*it;
  39. }
  40. ll t;
  41. for(int j=1;j<=tot;j++){
  42. t=a[j];
  43. while((1e18)/t>b[i] ){
  44. myset.insert(t*b[i]);
  45. t*=b[i];
  46. }
  47. }
  48. }
  49. }
  50. int main()
  51. {
  52. int n,m,i,j;
  53. init();
  54. scanf("%d",&n);
  55. ll num;
  56. int cnt=0;
  57. for(i=1;i<=n;i++){
  58. scanf("%I64d",&num);
  59. if(num==1){
  60. printf("YES\n");continue;
  61. }
  62. it=myset.find(num);
  63. //printf("--%d\n",*it);
  64. if(it==myset.end())printf("NO\n");
  65. else printf("YES\n");
  66. }
  67. return 0;
  68. }

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. 【JavaWeb】HTML&CSS 基础

    HTML&CSS 基础 HTML 基础 HTML 标签 HTML标题:HTML 标题(Heading)是通过 h1 - h6 等标签进行定义的. HTML段落: HTML 段落是通过 p 标签 ...

  2. LeetCode485 最大连续1的个数

    给定一个二进制数组, 计算其中最大连续1的个数. 示例 1: 输入: [1,1,0,1,1,1] 输出: 3 解释: 开头的两位和最后的三位都是连续1,所以最大连续1的个数是 3. 注意: 输入的数组 ...

  3. 【IMP】导出的时候显示ddl建表语句

    导出数据后,在导入的时候想要显示出建表语句,可以用show=y这个选项来实现 imp test/test file=test.dmp ignore=y show=y fromuser=test1 to ...

  4. 【Oracle】查看表空间是否为自动扩展

    查看指定的表空间是否为自动扩展 SQL>   select file_name,autoextensible,increment_by from dba_data_files where tab ...

  5. CTFHub - Misc(流量分析)

    数据库类流量: MySQL流量: 1.下载附件,是一个.pcap文件,用wireshark分析, 2.搜索ctfhub字段,即可得到flag, flag: ctfhub{mysql_is_S0_E4s ...

  6. (数据科学学习手札104)Python+Dash快速web应用开发——回调交互篇(上)

    本文示例代码已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 这是我的系列教程Python+Dash快速web ...

  7. 5V充12.6V三节锂电池,5V升压12.6V的电路图

    三串锂电池的充电电压是三串锂电池的最高电压值,就是12.6V了.5V充12.6V是5V给三串锂电池充电.如笔记本的USB口5V给三串锂电池充电,如5V的适配器或者手机充电器插上数据线给三串锂电池充电电 ...

  8. css-前端实现左中右三栏布局的常用方法:绝对定位,圣杯,双飞翼,flex,table-cell,网格布局等

    1.前言 作为一个前端开发人员,工作学习中经常会遇到快速构建网页布局的情况,这篇我整理了一下我知道的一些方法.我也是第一次总结,包括圣杯布局,双飞翼布局,table-cell布局都是第一次听说,可能会 ...

  9. 夯实基础系列四:Linux 知识总结

    前言 前三节内容传送门: 夯实基础系列一:Java 基础总结 夯实基础系列二:网络知识总结 夯实基础系列三:数据库知识总结 现在很多公司项目部署都使用的是 Linux 服务器,互联网公司更是如此.对于 ...

  10. C指针的这些使用技巧,掌握后立刻提升一个Level

    这是道哥的第016篇原创 关注+星标公众号,不错过最新文章 目录 一.前言 二.八个示例 1. 开胃菜:修改主调函数中的数据 2. 在被调用函数中,分配系统资源 2.1 错误用法 2.2 正确用法 3 ...