题解 【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. 树链剖分数据结构板题 题目大意:我 ...
随机推荐
- JMeter性能监控插件PerfMon Metrics Collector
Jmeter性能监控插件由客户端插件和服务器端程序组成. 官方文档及插件下载地址https://jmeter-plugins.org/wiki/PerfMon/ 将插件 plugins-manager ...
- LAMP搭建随笔
前言 这是我第一次在写博客,里面记录了我配置LAMP遇到的各种各样的细节,也许表述不够准确,希望大佬给于批评指正 环境 OS Ubuntu server 18.04.3 远程连接软件 cmder 文件 ...
- windows2016_x64搭建ELK(datasource->filebeat->logstash->elasticsearch->kibana)
windows2016_x64搭建ELK(datasource->filebeat->logstash->elasticsearch->kibana) 本文示例日志程序基于as ...
- 小白的java学习之路 “ 二重循环”
二重循环: 1.什么是二重循环: 一个循环体内又包含另一个完整的循环结构 语法: while(循环条件1) { //循环操作1 while(循环条件2) { //循环操作2 } } do { //循环 ...
- 从Windows10中彻底删除【3D对象】文件夹
Remove "3D object" folder from My Computer Windows Registry Editor Version 5.00 [-HKEY_LOC ...
- SpringJpa CRUD 代码生成器
利用业余时间撸了一个Spring Jpa代码生成器jpa-codegen. 简介 这是一款基于Freemarker模板驱动的代码生成器. 依据现有的实体类代码,自动生成CRUD代码,解放双手,加快开发 ...
- LAMP(七)之编译安装php(模块化和fpm两种方式)
安装前说明: 安装环境: CentOS6 安装应用程序:httpd2.4 + mariadb + php 安装次序: 先编译安装 httpd2.4和mariadb,最后安装php 编译安装 httpd ...
- oracle add_month函数
本文转自:https://blog.csdn.net/lanchengxiaoxiao/article/details/7695057 add_months 函数主要是对日期函数进行操作,举例子进行说 ...
- IO流学习之字符流(三)
IO流之字符流缓冲区: 概念: 流中的缓冲区:是先把程序需要操作的数据保存在内存中,然后我们的程序读写数据的时候,不直接和持久设备之间交互,而改成和内存中的数据进行交互. 缓冲区:它就是临时存储数据, ...
- Win10下安装tensorflow详细过程
首先声明几点: 安装tensorflow是基于Python的,并且需要从Anaconda仓库中下载. 所以我们的步骤是:先下载Anaconda,再在Anaconda中安装一个Python,(你的电脑里 ...