B. Navigation System【CF 1320】】的更多相关文章

传送门 题目:简单理解就是,我们需要开车从s点到t点.车上有一个导航,如果当前点为x,则导航会自动为你提供一条从x到t的最短的路线(如果有多条,则随机选一条),每走到下一个点则会实时更新最短路线,当然,如果你按着之前提供的路线走到下一个点,则路线不会更新.题目提供一条确定的路线,如果按着提供的路线走,问导航最多会更新几次,最少会更新几次. 思路:切入点很简单,我们按着路线一个个点走,需要确定走到该点的时候,该点是不是包含在最短路线中,如果包含,是不是唯一的,如果唯一,不更新,否则更新:如果不包含…
[题目描述] 有一张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\…
time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Berland amusement park shooting gallery is rightly acknowledged as one of the best in the world. Every day the country's best shooters maste…
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…