codeforces#687 B. Remainders Game
题意:给出n个数,和一个数p,问你在知道 x%ai 的情况下,能不能确定x%p的值
结论:当n个数的最小公倍数是p的倍数时,可以确定
代码:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e6+10;
vector<int>ve;
int n,p;
int main()
{
scanf("%d %d",&n,&p);
for(int i=2; i*i<=p; i++)
{
if(p%i==0)
{
ll res=i;
while(p%(res*i)==0&&p>=(res*i))
res*=i;
p/=res;
ve.push_back(res);
}
}
if(p!=1)ve.push_back(p);
for(int i=1; i<=n; i++)
{
int x;
scanf("%d",&x);
for(int i=0; i<ve.size(); i++)
{
if(ve[i]==0)continue;
if(x%ve[i]==0)ve[i]=0;
}
}
for(int i=0; i<ve.size(); i++)
if(ve[i]!=0)
{
cout<<"No"<<endl;
return 0;
}
cout<<"Yes"<<endl;
return 0;
}
codeforces#687 B. Remainders Game的更多相关文章
- codeforces 360 D - Remainders Game
D - Remainders Game Description Today Pari and Arya are playing a game called Remainders. Pari choos ...
- codeforces 688D D. Remainders Game(中国剩余定理)
题目链接: D. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input stan ...
- 【16.56%】【codeforces 687B】Remainders Game
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces Educational Codeforces Round 5 E. Sum of Remainders 数学
E. Sum of Remainders 题目连接: http://www.codeforces.com/contest/616/problem/E Description The only line ...
- Codeforces Round #360 (Div. 2) D. Remainders Game 数学
D. Remainders Game 题目连接: http://www.codeforces.com/contest/688/problem/D Description Today Pari and ...
- Codeforces 687B. Remainders Game[剩余]
B. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- codeforces 616E Sum of Remainders (数论,找规律)
E. Sum of Remainders time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Educational Codeforces Round 5 E. Sum of Remainders (思维题)
题目链接:http://codeforces.com/problemset/problem/616/E 题意很简单就不说了. 因为n % x = n - n / x * x 所以答案就等于 n * m ...
- Codeforces Round #360 (Div. 2) D. Remainders Game 中国剩余定理
题目链接: 题目 D. Remainders Game time limit per test 1 second memory limit per test 256 megabytes 问题描述 To ...
随机推荐
- C#-类(九)
类的定义 类是描述具有相同特征与行为的事物的抽象,类内部包含类的特征和类的行为 类支持继承 类的定义是关键字class为标志 类的格式 访问标识符 class 类名 { 类主体 } 访问标识符:指定了 ...
- C#计算时间差 TimeSpan
TimeSpan的相关属性 Add:与另一个TimeSpan值相加. Days:返回用天数计算的TimeSpan值. Duration:获取TimeSpan的绝对值. Hours:返回用小时计算的Ti ...
- Mysql --学习:大量数据快速导入导出
声明:此文供学习使用,原文:https://blog.csdn.net/xiaobaismiley/article/details/41015783 [实验背景] 项目中需要对数据库中一张表进行重新设 ...
- irc 关键操作
IRC 客户端: Textual 5 HexChat IRC 用户密码常用命令: 用户密码: 忘记密码 如果太长时间没登录IRC,难免会忘记密码,那IRC有重置密码的功能吗?当然有,不过也是通过命令 ...
- Linux: 软件包管理之rpm与yum [转]
软件包的安装和卸载时很平常的事,但在Linux上面却不简单..Linux的其中一个哲学就是一个程序只做一件事,并且做好.组合小程序来完成复杂的任务,这样做有很多好处,但是各个小程序之间往往会存在着复杂 ...
- Microsoft .NET Framework 3.5 离线安装方法 (仅适用于Win8以上的系统)
所需工具:本系统对应原版镜像或Win8以上操作系统原版ISO镜像 操作: 1.利用Windows资源管理器挂载 ISO 镜像,或其他虚拟光驱工具挂载镜像,记住挂载的盘符 2.打开Windows命令提示 ...
- 老生常谈:Windows的7类安全漏洞
这是篇比较老的文章,但是现在翻出来发下,还是会让大家对Windows的安全漏洞有所了解.建议大家阅读<软媒原创:如何从根上保证电脑安全.不中毒>. 目前微软系列产品中,危害计算机安全的漏洞 ...
- LeetCode算法题-Symmetric Tree(Java实现)
这是悦乐书的第163次更新,第165篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第22题(顺位题号是101).给定二叉树,检查它是否是自身的镜像(即,围绕其中心对称). ...
- android开发——用户头像
最近,小灵狐得知了一种能够加快修炼速度的绝世秘法,那便是修炼android神功.小灵狐打算用android神功做一个app,今天他的修炼内容就是头像功能.可是小灵狐是个android小白啊,所以修炼过 ...
- 【Teradata Utility】系统工具使用
List two ways in which a system utility can be started. Explain how to use the following utilities t ...