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 ...
随机推荐
- Markdonw基本语法学习
Markdonw基本语法 二级标题 三级标题 ----ctrl+r 粗体 ctrl+b 斜体 ctr+i #include<stdio.h> void main() { printf(&q ...
- scrapy实例:爬取中国天气网
1.创建项目 在你存放项目的目录下,按shift+鼠标右键打开命令行,输入命令创建项目: PS F:\ScrapyProject> scrapy startproject weather # w ...
- [TC]Total Command显示文件夹大小
在Windows下计算文件夹的大小 按下 Alt +Shift +Enter 将会计算当前目录下的文件夹大小. 关于TC相关的知识:TC(Total Commander)文件管理神器
- php判断手机是安卓系统还是ios系统
最近项目,要判断用户的手机是安卓的还是ios的,搜了一下相关的资料,最终获得的结果.事实证明,是有效的!主要是要用到HTTP_USER_AGENT,它表示的意思是用来检查浏览页面的访问者在用什么操作系 ...
- appium+robotframework常见技巧总结
1.如何输入中文 方法: 在open application参数最后,新增unicodeKeyboard=True resetKeyboard=True:不加入这两个参数时,中文无法输入 2.如 ...
- Linux 小知识翻译 - 「代理服务器」
这回聊聊「代理服务器」. 在公司里,不通过代理服务器无法连接互联网的,由于代理服务器的原因,有些服务的使用是受到限制的. 有人可能会觉得为什么会存在这种东西?(这里指代理服务器) Proxy本来的意思 ...
- #010 全年级C语言开始统一刷题了,能否坚持下去?
不知道这是咋回事吧,这个系统挺不好使得,出现了一个又一个的问题. 使用过程中做题的那个系统自己就崩了,刷新后那道题得了零分. 前面的几道题难度系数也不小,对于我这个新手来说,但是这个系统太坑了.他明码 ...
- Java访问级别修饰符
用途 控制其他类可以访问的字段或方法 修饰符 public.protected.no modifier(未声明).private 访问级别 修饰符 当前类 包 子类 其他包 public √ √ √ ...
- Python闭包和装饰器再复习
闭包 闭包的定义 在一个外函数中定义了一个内函数,并且内函数用到了外部函数的变量,而且外函数的返回值是内函数的引用,这就构成了一个闭包. 一般情况下,在我们认知当中,如果一个函数结束,函数的内部所有东 ...
- wangedit
<template> <el-row id="AddRoom"> <el-col :span="5">.</el-co ...