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 ...
随机推荐
- Python比较(关系)运算符
比较(关系)运算符 运 算 符 作 用 举 例 结 果 > 大于 'a'>'b' False < 小于 156<456 True == 等于 'c' ...
- JavaScript闭包理解【关键字:普通函数、变量访问作用域、闭包、解决获取元素标签索引】
一.闭包(Closure)模糊概述 之前总觉得闭包(Closure)很抽象而且难理解,百度一下"闭包"名词,百度的解释是:“闭包是指可以包含自由(未绑定到特定对象)变量的代 ...
- docker pull下载镜像报错Get https://registry-1.docker.io/v2/library/centos/manifests/latest:..... timeout
使用docker pull从镜像仓库拉取镜像时报错如下:[root@docker-registry ~]# docker pull centosUsing default tag: latestTry ...
- vue中$router.push打开新窗口
在vue中使用 this.$router.push({ path: '/home' }) 默认是替代本窗口 如果想新开一个窗口,可以使用下面的方式: let routeData = this.$ro ...
- 从n个数里面选择m个数
从n个数里面选择m个数 #include<iostream> #include<vector> using namespace std; vector<int> s ...
- 设计模式のIOC(控制反转)
一.什么是Ioc IoC(Inverse of Control)的字面意思是控制反转,它包括两个内容: 控制.反转 可以假设这样一个场景:火车运货,不同类型的车厢运送不同类型的货物,板车运送圆木,罐车 ...
- Linux系统安装和网络配置
系统下载 CentOS 6.x 50% 6.9 ---- 常用 CentOS 7.x 50% 7.2 ----常用 官网-国外 https://wiki.centos.org/Downloa ...
- spring Environment
Environment 环境在容器中是一个抽象的集合,是指应用环境的2个方面: profiles和 properties. profile 配置是一个被命名的,bean定义的逻辑组,这些bean只有在 ...
- 【转】iOS弹幕库OCBarrage-如何hold住每秒5000条巨量弹幕
最近公司做新需求, 原来用的老弹幕库, 已经无法满足需要. 迫不得已自己写了一套弹幕库OCBarrage. 这套弹幕库轻量, 可拓展, 高度自定义, 超高性能, 简单易上手. 无论哪家公司软件的性能绝 ...
- sku回忆笔记
分类表:(商品分类编号, 分类名称, 父分类编号)(1, 男装, 0)(2, 裤子, 1)(3, 外套, 1)(4, 内裤, 1)(5, 袜子, 1) 商品表:(商品编号, 商品名称, 商品分类编号, ...