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 ...
随机推荐
- java中BigDecimal加减乘除基本用法
Java在java.math包中提供的API类BigDecimal,用来对超过16位有效位的数进行精确的运算.双精度浮点型变量double可以处理16位有效数. 在实际应用中,需要对更大或者更小的数进 ...
- emacs + quicklisp + slime
- Android 去除最上面应用名称及图标
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); r ...
- SQL SERVER 2008 登陆失败(SQL和windows都没有对应的权限)
转自:http://www.cnblogs.com/zerocc/p/3425431.html 昨天在测试一些权限今天早上来就发现SQL SERVER 登陆不上去,报错为: 用户登陆失败:消息 184 ...
- jquery判断id是否存在
1.判断标签是否存在 ){ 存在 } 2.判断(id="id名"的标签)是否存在,下面的不可以!!!因为 $("#id") 不管对象是否存在都会返回 objec ...
- PetaPoco的几个特性
在PetaPoco中,Brad并没有定义太多Attribute来修饰Models或Fields.这些为数不多的几个Attribute如下: ColumnAttribute ExplicitColumn ...
- selenium—JS点击方法
package com.allin.pc;import java.util.NoSuchElementException;import org.openqa.selenium.By;import or ...
- ubuntu删除软件命令
第一步,apt-get remove xxx :就是卸载xxx 或者 apt-get remove --purge xxx :卸载xxx并清除配置. 这两条命令对于依赖则是不管的.因为别的软件可 ...
- Java开发中经典的小实例-(打印九九乘法表)
public class Test16 { public static void main(String[] args) { // TODO Auto-generated meth ...
- LTE Module User Documentation(翻译13)——频率复用算法(Frequency Reuse Algorithms)
LTE用户文档 (如有不当的地方,欢迎指正!) 19 Frequency Reuse Algorithms(频率复用算法) 本节我们将描述如何在 LTE 仿真中使用频率复用(FR)算法.共有两 ...