传送门

分解质因数,不说了

这题坑了我2个多小时

教训

不熟悉位运算的优先级一定要加括号!!!!

#include <cstdio>
#include <iostream>
#define N 1000001
#define LL long long
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y)) int n, m1, m2, m, sum, ans = 1e9, tot, t = 1, p;
int b[N], c[N];
bool f; inline int read()
{
int x = 0, f = 1;
char ch = getchar();
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
for(; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
return x * f;
} inline int gcd(int x, int y)
{
return !y ? x : gcd(y, x % y);
} int main()
{
int i, j, a, x;
n = read();
m1 = read();
m2 = read();
if(m1 == 1)
{
puts("0");
return 0;
}
x = m1;
for(j = 2; j <= m1; j++)
{
while(!(x % j)) c[t] = j, b[t]++, x /= j;
b[t] *= m2;
if(b[t]) t++;
}
t--;
for(i = 1; i <= n; i++)
{
sum = f = 0;
p = 1;
x = a = read();
if(gcd(m1, a) == 1) continue;
for(j = 2; j <= a; j++)
{
tot = 0;
while(!(x % j)) tot++, x /= j;
if(tot && c[p] == j) sum = max(sum, b[p] / tot + (b[p] % tot != 0)), p++;
if(c[p] < j) break;
}
if(p > t) ans = min(ans, sum);
}
printf("%d\n", ans == 1e9 ? -1 : ans);
return 0;
}

  

最新文章

  1. 一起学微软Power BI系列-官方文档-入门指南(3)Power BI建模
  2. 您不能在64位可执行文件上设置DEP属性
  3. android view:布局优化
  4. web攻防
  5. [SQL]oracle 的to_char、to_number、to_date用法
  6. 《C程序设计的抽象思维》1.9编程练习
  7. 神奇的fastcgi_finish_request
  8. Quartz 2D画虚线-b
  9. SQL的定义与使用
  10. 演示:纯CSS实现自适应布局表格
  11. (转)javaScript call 函数的用法说明
  12. TCP/IP-IP
  13. 标准简单SP模板(oracle)
  14. 关于Go语言共享内存操作的小实例
  15. MVC-Easy-UI-datagrid-分页-查询
  16. iOS_21团购_发送请求【点评】数据
  17. 微信小程序对医疗创业的启示,“餐饮+微信小程序”的猜想
  18. NGINX 配置404错误页面转向
  19. 在vue中使用css modules替代scroped
  20. 3;XHTML排列清单控制标记

热门文章

  1. macbookpro安装Ubuntu16.04.1 LTS爬坑之旅。亲测有效(集众家之长)。安装时间为2017-11-19。
  2. 认识 jQuery (第一笔 点出重点)
  3. P2668 斗地主 dp+深搜版
  4. python 模块-easygui.buttonbox
  5. 联想 Z5(L78011) 免解锁BL 免rec 保留数据 ROOT Magisk Xposed 救砖 ZUI 10.5.254
  6. mongo 3.4分片集群系列之一:浅谈分片集群
  7. oracle添加联合主键
  8. STA之Concepts (1)
  9. JSP学习笔记 - 内置对象 Response
  10. (转)淘淘商城系列——使用solrj来测试索引库