题意:给定 n 个数,一个数 k,然后你知道一个数 x 取模这个 n 个的是几,最后问你取模 k,是几. 析:首先题意就看了好久,其实并不难,我们只要能从 n 个数的最小公倍数是 k的倍数即可,想想为什么.如果考虑用 k 除以最大公约数是错误的, 因为可能存在相同的因数,这个是不能算的. 代码如下: #include <iostream> #include <cstdio> #include <algorithm> #include <vector> #in…
题意:给你x%ci=bi(x未知),是否能确定x%k的值(k已知) ——数学相关知识: 首先:我们知道一些事情,对于k,假设有ci%k==0,那么一定能确定x%k的值,比如k=5和ci=20,知道x%20=y,那么ans=x%k=y%5; 介绍(互质版)中国剩余定理,假设已知m1,m2,mn,两两互质,且又知道x%m1,x%m2..x%mn分别等于多少 设M=m1*m2*m3..mn,那么x在模M的剩余系下只有唯一解(也就是知道了上面的模线性方程组,就可以求出x%M等于多少) ——此题解法 针对…
B. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Pari and Arya are playing a game called Remainders. Pari chooses two positive integer x and k, and tells Arya k but…
数论. 如果$x$不唯一,假设存在两个解,较大的为${x_1}$,较小的为${x_2}$. 那么, $\left\{ {\begin{array}{*{20}{c}}{{x_1}\% {c_i} = {x_2}\% {c_i}}\\{{x_1}\% k \ne {x_2}\% k}\end{array}} \right. \Rightarrow \left\{ {\begin{array}{*{20}{c}}{({x_1} - {x_2})\% {c_i} = 0}\\{({x_1} - {x_…
D. Remainders Game 题目连接: http://www.codeforces.com/contest/688/problem/D Description Today Pari and Arya are playing a game called Remainders. Pari chooses two positive integer x and k, and tells Arya k but not x. Arya have to find the value . There…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Today Pari and Arya are playing a game called Remainders. Pari chooses two positive integer x and k, and tells Arya k but not x. Arya have to fin…
题意:第一行给两个数,n 和 A,n 表示有n 个骰子,A表示 n 个骰子掷出的数的和.第二行给出n个数,表示第n个骰子所能掷出的最大的数,这些骰子都有问题, 可能或多或少的掷不出几个数,输出n个骰子掷不出的数的个数. 析:我们只要考虑两个极端就好,考由其他骰子投出的最大值和最小值,还有自身在最大值和最小值,作一个数学运算就OK了.公式如下: 骰子的最大值-能投的最大值+能投的最小值-1. 代码如下: #include <cstdio> #include <string> #inc…
Garage 题目连接: http://codeforces.com/gym/100269/attachments Description Wow! What a lucky day! Your company has just won a social contract for building a garage complex. Almost all formalities are done: contract payment is already transferred to your a…
题目链接:http://codeforces.com/contest/1206/problem/C 题解 : 观察可以发现当n为偶数时,1 - 2n是不满足题意的,可以举例n = 2,n = 4试一试.那么当n为奇数时,则满足题意,通过n = 3和n = 5的情况可以发现一个规律,当a[ 1 ] = 1时候,a[ n + 1] = 2 ,a[ 2 ] =  4,此时 a[ n + 1]  = 3,a[ 3 ] = 5,则a[ n+ 3] = 6,发现a[ i ] 和a[ i + n] 是连续的两…
题目链接: C. Vectors time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output At a geometry lesson Gerald was given a task: to get vector B out of vector A. Besides, the teacher permitted him to perform…