题解 【Codefoeces687B】Remainders Game
题意:
给出c1,c2,...cn,问对于任何一个正整数x,给出x%c1,x%c2,...的值x%k的值是否确定;
思路:
中国剩余定理。详见https://blog.csdn.net/acdreamers/article/details/8050018
代码:
#include<bits/stdc++.h>//万能头文件
using namespace std;//使用标准名字空间
long long gcd(long long a,long long b){//使用递归求两个数的最大公因数
if(b==) return a;//如果有一个数为0,就返回另一数
return gcd(b,a%b);//否则递归下一层
}
long long n,m;
int main()
{
cin>>n>>m;//输入n和m
long long x,ans=;//定义各数初值
while(n--){
scanf("%lld",&x);//输入序列
ans=ans/gcd(ans,x)*x%m;//求它们的最小公倍数
}
if(ans%m)cout<<"No"<<endl;//如果不是m的倍数,就输出“NO”
else cout<<"Yes"<<endl;//否则输出“Yes”
return ;//结束
}
题解 【Codefoeces687B】Remainders Game的更多相关文章
- Codeforces 687B. Remainders Game[剩余]
B. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- 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 time limit per test 1 second memory limit per test 256 megabytes 问题描述 To ...
- Codeforces 999D Equalize the Remainders (set使用)
题目连接:Equalize the Remainders 题意:n个数字,对m取余有m种情况,使得每种情况的个数都为n/m个(保证n%m=0),最少需要操作多少次? 每次操作可以把某个数字+1.输出最 ...
- leetcode & lintcode 题解
刷题备忘录,for bug-free 招行面试题--求无序数组最长连续序列的长度,这里连续指的是值连续--间隔为1,并不是数值的位置连续 问题: 给出一个未排序的整数数组,找出最长的连续元素序列的长度 ...
- Codeforces Round #360 (Div. 2) D. Remainders Game 数学
D. Remainders Game 题目连接: http://www.codeforces.com/contest/688/problem/D Description Today Pari and ...
- 【16.56%】【codeforces 687B】Remainders Game
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- CoderForces999D-Equalize the Remainders
D. Equalize the Remainders time limit per test 3 seconds memory limit per test 256 megabytes input s ...
- 2016 华南师大ACM校赛 SCNUCPC 非官方题解
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...
随机推荐
- Q函数和值函数
Q函数:奖励和 总奖励是在状态st采取行为at的奖励的期望和 值函数:奖励和 总奖励是在状态st下获得的奖励的期望和 下面是值函数另外的定义,在at行为下采取策略的Q函数的期望 是RL的目标函数,我理 ...
- luogu P3384 【模板】重链剖分
参考https://www.cnblogs.com/wushengyang/p/10808505.html,感谢 #include<iostream> #include<algori ...
- dir()和vars()的区别就是
------------恢复内容开始------------ dir()只打印属性(属性,属性......) 而vars()则打印属性与属性的值(属性:属性值......) >> a='a ...
- mysql-主从备份问题小结
一:防火墙 常用命令 firewall-cmd --state 或 systemctl status firewalld # 查看状态 systemctl start firewalld# 启动 sy ...
- python神器pycharm的安装
1.下载PyCharm 官网下载:http://www.jetbrains.com/pycharm/download/#section=windows百度网盘下载:https://pan.baidu. ...
- NoSQLBooster如何MongoDB的部分文档从一个集合拷贝到另外一个集合中
假设MongoDB数据库中存有collection_A和collection_B两个集合,如下图所示: (一)先从集合collection_A中拷贝选择的文档 打开collection_A,看到目前有 ...
- [PAT] A1023 Have Fun with Numbers
[题目大意] 给一个不超过20位的数字,如果将它乘以2得到的数仅仅是原来的数字重新排列得到的,那就输出Yes,下一行输出加倍后的数.如果不是,输出No,下一行输出加倍后的数. [思路] 20位过于庞大 ...
- H5_0024:对于事先无法确定css大小的情况,可以通过JS动态修改
$(function(){ function Heights(){ var WinH = $(window).height(); ...
- 一、JVM之类加载器
一.什么是JVM 先来看下百度百科的解释: JVM 是 Java Virtual Machine(Java 虚拟机)的缩写,JVM 是一种用于计算设备的规范,它是一个虚构出来的计算机,是通过在实际的计 ...
- jQuery---html方法和text方法
html方法和text方法 //html:innerHTML text:innerText console.log($("div").html());//<h3>我是标 ...