题意:给出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的更多相关文章

  1. codeforces 360 D - Remainders Game

    D - Remainders Game Description Today Pari and Arya are playing a game called Remainders. Pari choos ...

  2. codeforces 688D D. Remainders Game(中国剩余定理)

    题目链接: D. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input stan ...

  3. 【16.56%】【codeforces 687B】Remainders Game

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 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 ...

  5. Codeforces Round #360 (Div. 2) D. Remainders Game 数学

    D. Remainders Game 题目连接: http://www.codeforces.com/contest/688/problem/D Description Today Pari and ...

  6. Codeforces 687B. Remainders Game[剩余]

    B. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  7. codeforces 616E Sum of Remainders (数论,找规律)

    E. Sum of Remainders time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  8. Educational Codeforces Round 5 E. Sum of Remainders (思维题)

    题目链接:http://codeforces.com/problemset/problem/616/E 题意很简单就不说了. 因为n % x = n - n / x * x 所以答案就等于 n * m ...

  9. Codeforces Round #360 (Div. 2) D. Remainders Game 中国剩余定理

    题目链接: 题目 D. Remainders Game time limit per test 1 second memory limit per test 256 megabytes 问题描述 To ...

随机推荐

  1. c# 采用datatable 快速导入数据至MSSQL的方法分享

    转自:http://www.maomao365.com/?p=5613 摘要:下文讲述使用c#代码快速将dataTable导入至mssql数据库的方法 实现思路:需要将datatable调整为同目标表 ...

  2. python黑帽子

    1.TCP客户端 #AF_INET 使用标准的IPv4地址或者主机名 #SOCK_STREAM是一个客户端 import socket target_host = 'www.google.com' t ...

  3. gcc5.4报错对‘std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()’未定义的引用

    我在编译ligra是遇到了这个问题,网上搜了一遍,发现是了原因https://gcc.gnu.org/onlinedocs/libstdc%2B%2B/manual/using_dual_abi.ht ...

  4. C# 隐藏最大化、最小化和关闭三个按钮

    在Windows的窗体编程中,基本上每一个窗体都是一个最小化.最大化和关闭按钮的. 一.禁用最大化和最小化 对于最大化和最小化按钮,在C#窗体开发时,各一个属性来启用或禁用这两个按钮. this.Ma ...

  5. input reset 重置时间

    经验规律,301毫秒. function autoFormatMoney() { if (!this.value.length) {return} var num = parseFloat(this. ...

  6. 设计模式のFilterPattern(过滤器模式)----结构模式

    一.产生背景 我们有一堆“人”的对象,我们应该怎么选择出其中的男性.女性或者其他类型的呢?这时候我们可以用过滤器模式 二.通常做法 我们将创建一个 Person 对象.Criteria 接口和实现了该 ...

  7. Thread.interrupt()

        作者:Intopass链接:https://www.zhihu.com/question/41048032/answer/89431513来源:知乎著作权归作者所有.商业转载请联系作者获得授权 ...

  8. Web开发人员vs网页设计师

    Web开发人员vs网页设计师 我们都遇到过,但实际的区别是什么?如果您是该领域的新手,请阅读详细内容,这些内容比您想象的更重要. 经过几周(或几个月)的规划和准备,进行市场调查,与其他企业家交谈,现在 ...

  9. Problem UVA11134-Fabled Rooks(贪心)

    Problem UVA11134-Fabled Rooks Accept: 716  Submit: 6134Time Limit: 3000mSec Problem Description We w ...

  10. 通过 PHP,可以把文件上传到服务器。

    创建一个文件上传表单 允许用户从表单上传文件是非常有用的. 请看下面这个供上传文件的 HTML 表单: <html> <body> <form action=" ...