CF1647D Madoka and the Best School in Russia 做题记录
我不会分讨。
可以知道一个美丽数
有个朴素的想法是将给你的
- 显然如果
那么我们拆不动。 - 如果
可以拆成大于 个数的乘积,那么是可行的。 - 如果
是质数,那么我们就拆 。- 如果
是质数,就拆不了了。 - 如果
不是质数:- 如果有个不是
的质因子,那么是可行的。 - 如果
,那么是不可行的。 - 现在
。- 如果
且 ,那么可行; - 如果
且 ,那么可行。
- 如果
- 如果有个不是
- 如果
点击查看代码
#include<bits/stdc++.h>
#define int ll
#define mem(a,b) memset((a),(b),sizeof(a))
#define m0(a) memset((a),0,sizeof(a))
#define lb(x) ((x)&-(x))
#define lc(x) ((x)<<1)
#define rc(x) (((x)<<1)|1)
#define pb(G,x) (G).push_back((x))
#define For(a,b,c) for(int a=(b);a<=(c);a++)
#define Rep(a,b,c) for(int a=(b);a>=(c);a--)
#define in1(a) a=read()
#define in2(a,b) a=read(), b=read()
#define in3(a,b,c) a=read(), b=read(), c=read()
#define inn(i,n,a) For(i,1,n) a[i]=read();
#define ll long long
#define i128 __int128
using namespace std;
inline int read() {
int xx= 0;int f= 1;
char c = getchar();
while(c<'0'||c>'9') {
if(c=='-') f= -1;
c= getchar();
}
while(c>='0'&&c<='9') {
xx= (xx<<1)+(xx<<3)+(c^48);
c= getchar();
}
return xx*f;
}
#define maxn 200050
int x,d;
void work() {
in2(x,d);
int cnt=0;
while(x%d==0) x/=d,cnt++;
if(cnt<2) return cout<<"NO\n",void();
for(int i=2;i*i<=x;i++) {
if(x%i==0) return cout<<"YES\n",void();
}
bool pr=1;
for(int i=2;i*i<=d;i++)
if(d%i==0) {
pr=0;
break;
}
if(pr) return cout<<"NO\n",void();
if(cnt>2) {
for(int i=2;i*i<=d;i++)
if(d%i==0&&(i!=x||(d/i!=x))) return cout<<"YES\n",void();
}
if(x==1) return cout<<"NO\n",void();
int cnt2=0;
while(d%x==0) cnt2++,d/=x;
if(cnt2>2&&cnt>2) return cout<<"YES\n",void();
if(cnt2==2&&cnt>3) return cout<<"YES\n",void();
return cout<<"NO\n",void();
}
signed main() {
int _=read();
while(_--) work();
}
本文来自博客园,作者:coding_goat_qwq,转载请注明原文链接:https://www.cnblogs.com/CodingGoat/p/18536867
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现