CodeForces 688D-Remainders Game
题意:
已知n, k与n个整数(c1,c2,...,cn),问你是否存在一个数x,使得它能被n个整数且k整除.
分析:
可以先将n个整数的最小公倍数lcm计算出来,再判断它是否能被k整除.
代码如下:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <iterator>
#include <vector> using namespace std; #define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 10000010
#define MAXM 1000010 LL gcd(LL m, LL n)
{
LL a, b;
a = m;
b = n;
if(a < b)
{
LL temp;
temp = a;
a = b;
b = temp;
}
while(b != )
{
LL temp;
temp = a%b;
a = b;
b = temp;
}
return a;
} LL lcm(LL x, LL y)
{
return x/gcm(x, y)*y;
} int main()
{
int n, k;
LL ans, m;
while(scanf("%d%d", &n, &k)==)
{
int i;
ans = ;
for(i = ; i <= n; i++ )
{
scanf("%lld", &m);
ans = lcm(ans, m)%k;
}
if(ans == )
printf("Yes\n");
else
printf("No\n");
} return ;
}
CodeForces 688D-Remainders Game的更多相关文章
- codeforces 688D D. Remainders Game(中国剩余定理)
题目链接: D. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Codeforces 687B. Remainders Game[剩余]
B. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- codeforces 687B - Remainders Game 数学相关(互质中国剩余定理)
题意:给你x%ci=bi(x未知),是否能确定x%k的值(k已知) ——数学相关知识: 首先:我们知道一些事情,对于k,假设有ci%k==0,那么一定能确定x%k的值,比如k=5和ci=20,知道x% ...
- CodeForces 687B Remainders Game
数论. 如果$x$不唯一,假设存在两个解,较大的为${x_1}$,较小的为${x_2}$. 那么, $\left\{ {\begin{array}{*{20}{c}}{{x_1}\% {c_i} = ...
- CodeForces 687B Remainders Game(数学,最小公倍数)
题意:给定 n 个数,一个数 k,然后你知道一个数 x 取模这个 n 个的是几,最后问你取模 k,是几. 析:首先题意就看了好久,其实并不难,我们只要能从 n 个数的最小公倍数是 k的倍数即可,想想为 ...
- codeforces 688D
题意: 给你n和k,表示有n个数,c1到cn,然后让你求一个数x,可以告诉你x%ci的值,问你是否可以唯一确定一个x%k的值 题解: 反证: 假设有两个x1,x2同时是解,则对于所有ci,x1%ci= ...
- Codeforces Round #360 div2
Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现 ...
- 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 360 D - Remainders Game
D - Remainders Game Description Today Pari and Arya are playing a game called Remainders. Pari choos ...
随机推荐
- iOS开发Hessian
HessianKit使用参考资料比较少,通过摸索,把测试过程贴出来,代码很乱,未整理,先实现功能,再应用到项目中.供新手参考.如有问题,跟帖指正... HessianService与Java Serv ...
- 2.1.5 计算机网络协议: TCP/IP
应用程序阶段:妳打开浏览器,在浏览器上面输入网址列,按下 [Enter].此时网址列与相关数据会被浏览器包成一个数据, 并向下传给 TCP/IP 的应用层: 应用层:由应用层提供的 HTTP 通讯协议 ...
- 如何使用Android Studio开发/调试Android源码
本文是以源码中development/tools/idegen/README作为指导文档. 环境: Ubuntu 14.10,openJdk 1.7,Android Studio 1.0.2,andr ...
- 无法解决 equal to 运算中 "Chinese_PRC_CI_AS" 和 "SQL_Latin1_General_CP1_CI_AS" 之间的排序规则冲突。
select * from a, b where a.Code=b.Code collate Chinese_PRC_CI_AS
- [课程设计]Scrum 1.4 多鱼点餐系统开发进度(点餐页面框架布置)
Scrum 1.4 多鱼点餐系统开发进度 (点餐页面框架布置) 1.团队名称:重案组 2.团队目标:长期经营,积累客户充分准备,伺机而行 3.团队口号:矢志不渝,追求完美 4.团队选题:餐厅到店点餐系 ...
- (转)mysql中InnoDB表为什么要建议用自增列做主键
InnoDB引擎表的特点 1.InnoDB引擎表是基于B+树的索引组织表(IOT) 关于B+树 (图片来源于网上) B+ 树的特点: (1)所有关键字都出现在叶子结点的链表中(稠密索引),且链表中的关 ...
- IntelliJ IDEA使用(2)——IDEA配置Tomcat
如果网上流传的方法(即方法2)不能配置成功,点击加号什么都没有的话,请看方法一配置方法. 解决问题:intlellij IDEA配置tomcat点击加号没东西. 方法一:手动添加tomcat插件然后再 ...
- linux定时执行任务
(1)Linux下如何定时执行php脚本?(2)Linux下如何设置定时任务?(3)Crontab定时执行程序 核心提示:键入 crontab -e 编辑crontab服务文件 分为两种情况:(还有一 ...
- jquery中,size()和length()方法有啥区别
jquery中,size()和length()方法有啥区别? size()是jQuery提供的函数,而length是属性(不带括号). jQuery提供的源代码是这样的: size: function ...
- Oracle软件开发分析
软件开发的步骤可大致分为: 1.需求分析 2.系统设计 3.编码实现 4.系统测试 5.运行维护 student class 多对一 sno name age gender cid id c ...