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 ...
随机推荐
- 改int非空自增列为int可为空列
) --声明读取数据库所有数据表名称游标mycursor1 open mycursor1 --从游标里取出数据赋值到我们刚才声明的数据表名变量中 fetch next from mycursor1 i ...
- Events in ASP.NET Master and Content Pages
Content page PreInit event. Master page controls Init event. Content controls Init event. Master pag ...
- CSS 笔记六(Image/Attribute Selectors)
Image Opacity / Transparency The CSS opacity property is a part of the CSS3 recommendation. Example ...
- 2015弱校联盟(1) -J. Right turn
J. Right turn Time Limit: 1000ms Memory Limit: 65536KB frog is trapped in a maze. The maze is infini ...
- Entity Framework 第八篇 结构优化
在之前的文章里,业务层直接调用一个包装的仓储类入口,忽略了DAL层,在业务层绕过DAL直接调用仓储类似乎也没什么大的问题,但是这样做有一个很大的弊端,就是无法做到DAL层的原子操作的复用.假如多个业务 ...
- easyui combobox 带 checkbox
$('#cc').combobox({ url:'combobox_data1.json', method:'get', valueField:'id', textField:'text', pane ...
- [问题2014S11] 解答
[问题2014S11] 解答 我们先引用一下复旦高代书 P310 的习题 6, 其证明可参考白皮书 P257 的例 8.33: 习题6 设实二次型 \(f(x_1,x_2,\cdots,x_n)= ...
- Python3基础 reverse 将列表倒序排列
镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...
- Nordic Semiconductor nRF52832 蓝牙智能多协议单芯片解决方案荣获《中国电子商情》编辑选择奖
挪威奥斯陆 – 2016年4月11日 – Nordic Semiconductor ASA (OSE: NOD) 赢得<中国电子商情>颁发的"2015年编辑选择奖",其 ...
- Unity3d 脚本相互调用
unity中三种调用其他脚本函数的方法 第一种,被调用脚本函数为static类型,调用时直接用 脚本名.函数名().很不实用…… 第二种,GameObject.Find("脚本所在物体名& ...