题解 【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. 树链剖分数据结构板题 题目大意:我 ...
随机推荐
- 分布式配置中心:Spring Cloud Config
最近在学习Spring Cloud的知识,现将分布式配置中心:Spring Cloud Config的相关知识笔记整理如下.[采用 oneNote格式排版]
- .net core 3.0一个记录request和respose的中间件
参考资料 https://www.cnblogs.com/wybin6412/p/10944077.html RequestResponseLog.cs using System; using Sys ...
- Selenium实战(四)——unittest单元测试框架1
Python中的单元测试框架包含:doctest.unittest.pyttest.nose等,使用unittest单元测试框架不需要自行定义断言失败的提示,并且当一个测试函数执行失败后,后面的测试函 ...
- MVC的App_Data中看不到数据库mdf文件
点击运行后的页面去注册个账号,然后点击解决方案的‘显示所有文件就能看到了
- FastDFS 单机部署指南
简介 FastDFS是一个开源的分布式文件系统,官方介绍有详细的介绍,不多赘述.本文主要是FastDFS的搭建及采坑指南. Step By Step Guide 系统 阿里云ECS Ubuntu 16 ...
- TamperMonkey 使用指南以及脚本推荐
写在前面 Chrome浏览器是最适合开发者使用的浏览器,不仅仅是因为Chrome对于Js的友好支持,更是由于Chrome支持丰富且功能强大的插件,扩展了浏览器的功能和使用体验. 在这些插件里面,相信你 ...
- gulp常用插件之gulp-uglify使用
更多gulp常用插件使用请访问:gulp常用插件汇总 gulp-uglify这是一款使用UglifyJS缩小js文件. 更多使用文档请点击访问gulp-uglify工具官网. 安装 一键安装不多解释 ...
- web渗透漏洞靶场收集
最近将自己遇到过或者知道的web靶场链接奉上 0X01 DVWA 推荐新手首选靶场,配置简单,需下载phpstudy和靶场文件包,简单部署之后即可访问. 包含了常见的web漏洞(php的),每个漏洞分 ...
- windows命令提示符常用命令
1.进入某个磁盘 c: 进入c盘 d: 进入d盘 2.返回到根目录 cd \ 3.查看当钱路径下的文件和文件夹 dir 4.清空窗口内容 cls 5.关闭窗口 exit 6.返回上一级目录 cd . ...
- ubuntu set up 5 - VIM
Edit ~/.vimrc source vimrc: :so ~/.vimrc 1. ctrl - left/right 切换tabs https://vim.fandom.com/wiki/Usi ...