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#面向对象 类的继承
1.类的访问权限: public:跨程序集,命名空间,必须被using引用: internal:默认当前命名空间: 2.类成员的访问权限: private:私有的,只能当前类: protecte:受保 ...
- mssql sqlserver 验证整型函数分享
转自:http://www.maomao365.com/?p=6227 摘要: 下文将制作一个isnumber验证整型的函数,供在sql脚本中做数值判断,如下所示: 例: 实现原理:判断 是否包含特殊 ...
- php快速定位当前调用的类的位置
php快速定位当前调用的类的位置 $func = new ReflectionMethod('类名', '方法名'); $start = $func->getStartLine() - 1; $ ...
- 创建一个C++制作的包含Opencv功能的dll,供C#程序使用
目的:获取某图片指定位置的颜色. 实现该目的的方法有很多,但为了有助于扩充自己技术广度,所以决定采用标题中的方法来完成. 没有C++编程经验,也没有制作C++版Opencv语法经验,也没有制作dll的 ...
- 实验吧web题:
实验吧web题: 这个有点简单 因为刚了解sqlmap,所以就拿sqlmap来练练手了 1,先测试该页面是否存在sql注入漏洞 2.找到漏洞页面,复制url,然后打开sqlmap 先查看当前数据库 然 ...
- February 27th, 2018 Week 9th Tuesday
Great minds think alike. 英雄所见略同. If great minds really did think alike, then we would live in an unr ...
- JavaScript对象原型写法详解
体现对象原型分步式写法 //原型分步式写法 //构造函数 function Person(){} //对象原型 Person.prototype.name = 'Avensatr'; Pers ...
- git使用命令行拉取远程代码仓库中的分支至本地
1.本地创建文件夹用于存放拉取的代码 2.执行git init初始化文件夹 3.与远程代码仓库建立连接 git remote add origin git@github.com.wuylin/noth ...
- php面试题整理(四)
应该是group by username }
- 禅道Bug等级划分标准
一.严重程序 P1:致命(该问题在测试中较少出现,一旦出现应立即中止当前版本测试) 阻碍开发或测试工作的问题:造成系统崩溃.死机.死循环,导致数据库数据丢失, 与数据库连接错误,主要功能丧失,基本模块 ...