【CF #313】】的更多相关文章

B题为啥交换一下搜索顺序就会TLE啊QAQ C题原来要预处理乘法逆元才能过啊QAQ 我沙茶啊我QAQ[还是太弱 嗯A题就是道水题 B题就是字符串Hash+暴力搜 C题就是组合数+容斥原理…
[题目描述] 有一张N,M<=10^12的表格,i行j列的元素是gcd(i,j) 读入一个长度不超过10^4,元素不超过10^12的序列a[1..k],问是否在某一行中出现过 [题解] 要保证gcd(x,y)=a[i],显然x=lcm(a[1],a[2]……a[k]) 然后y%a[1]=0,即(y+i-1)%a[i]=0 即y%a[1]=0 y%a[2]=-1 …… y%a[n]=-(n-1) 这就转化为了中国剩余定理 求出y之后,只需验证gcd(x,y+i-1)=a[i]即可 /*******…
[题目描述] Bike是一位机智的少年,非常喜欢数学.他受到142857的启发,发明了一种叫做“循环数”的数. 如你所见,142857是一个神奇的数字,因为它的所有循环排列能由它乘以1,2,...,6(1到它的长度)得到.循环排列意味着将该数的一些数位从尾部挪到前面.例如,12345的循环排列包括:12345,51234,45123,34512,23451.值得一提的是,允许出现前导零.因此4500123和0123450都是0012345的循环排列.你可以看到142857满足条件的原因.以下六个…
题意 给你一棵 \(n\) 个点的树,每个节点有两个权值 \(a_i,b_i\). 从一个点 \(u\) 可以跳到以其为根的子树内的任意一点 \(v\)(不能跳到 \(u\) 自己),代价是 \(a_u\times b_v\). 求每个点跳到任意一个叶子的最小代价. \(n\le 10^5, -10^5\le a_i,b_i\le 10^5\) 题解 暴力 考虑暴力 \(dp\),设 \(dp_i\) 表示从叶子跳到 \(i\) 号点的最小代价. 则有转移 \(dp_u = \min\{a_u\…
A. Little Pony and Expected Maximum time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept…
E. Present for Vitalik the Philatelist time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Vitalik the philatelist has a birthday today! As he is a regular customer in a stamp store called 'Ro…
time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Author has gone out of the stories about Vasiliy, so here is just a formal task description. You are given q queries and a multiset A, initi…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Nowadays it is becoming increasingly difficult to park a car in cities successfully. Let's imagine a segment of a street as long as L meters…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today an outstanding event is going to happen in the forest - hedgehog Filya will come to his old fried Sonya! Sonya is an owl and she sleeps…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your hel…