题意:

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

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

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

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

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

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

  4. Codeforces 999D Equalize the Remainders (set使用)

    题目连接:Equalize the Remainders 题意:n个数字,对m取余有m种情况,使得每种情况的个数都为n/m个(保证n%m=0),最少需要操作多少次? 每次操作可以把某个数字+1.输出最 ...

  5. leetcode & lintcode 题解

    刷题备忘录,for bug-free 招行面试题--求无序数组最长连续序列的长度,这里连续指的是值连续--间隔为1,并不是数值的位置连续 问题: 给出一个未排序的整数数组,找出最长的连续元素序列的长度 ...

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

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

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

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

  8. CoderForces999D-Equalize the Remainders

    D. Equalize the Remainders time limit per test 3 seconds memory limit per test 256 megabytes input s ...

  9. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

随机推荐

  1. SpringBoot图文教程6—SpringBoot中过滤器的使用

    有天上飞的概念,就要有落地的实现 概念十遍不如代码一遍,朋友,希望你把文中所有的代码案例都敲一遍 先赞后看,养成习惯 SpringBoot 图文系列教程技术大纲 鹿老师的Java笔记 SpringBo ...

  2. 图片-定义select向下箭头样式

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  3. javascript生成指定位数的随机数

    <script type="text/javascript"> document.write("请输入要生成随机数的位数:"); // digit是 ...

  4. open Live Writer 代码插件安装

    1,第一步:下载open live writer插件,下载地址:http://www.cnblogs.com/memento/p/5995173.html 2,拷贝文件到Plugins目录(自己建立) ...

  5. H5网页布局+css代码美化

    HTML5的结构化标签,对搜索引擎更友好 li 标签对不利于搜索引擎的收录,尽量少用 banner图片一般拥有版权,不需要搜索引擎收录,因此可以使用ul + li <samp></s ...

  6. 【IDE】IDEA - 使用问题记录

    1.显示方法API:类似eclipse把鼠标放到方法上有api信息. setting/keymap中搜索 quick docs:(有说默认快捷键是ctrl+q,但我的不是待查找快捷键) 2.forea ...

  7. 一些实用的GitHub项目

    原文链接:http://www.louisvv.com/archives/2036.html 最近整理了一些在GitHub上比较热门的开源项目 关于GitHub,快速了解请戳这里 其中涵盖了:学习教程 ...

  8. 【UWP】在 UWP 中使用 Exceptionless 进行遥测

    2020年1月17日更新: nightly build 版本已发布 https://www.myget.org/feed/exceptionless/package/nuget/Exceptionle ...

  9. srpingboot web - 启动(3) 监听器

    接上一篇 一. getRunListeners() 在run() 方法中调用了 getRunListeners(args) 方法, 先看一下这个方法干了什么 private SpringApplica ...

  10. npm常用模块汇总

    npm常用模块汇总: 点击插件名字,查看使用文档 npm常用模块汇总 node常用模块汇总 gulp常用插件汇总 npx 使用教程:npx使用教程 bable:bable这是JavaScript编译器 ...