【CF#303D】Rotatable Number】的更多相关文章

[题目描述] Bike是一位机智的少年,非常喜欢数学.他受到142857的启发,发明了一种叫做“循环数”的数. 如你所见,142857是一个神奇的数字,因为它的所有循环排列能由它乘以1,2,...,6(1到它的长度)得到.循环排列意味着将该数的一些数位从尾部挪到前面.例如,12345的循环排列包括:12345,51234,45123,34512,23451.值得一提的是,允许出现前导零.因此4500123和0123450都是0012345的循环排列.你可以看到142857满足条件的原因.以下六个…
Palindrome Number Total Accepted: 19369 Total Submissions: 66673My Submissions Determine whether an integer is a palindrome. Do this without extra space. 推断一个数整数是不是回文?比如121,1221就是回文,好吧,直接利用前面写过的[Leet Code]Reverse Integer--"%"你真的懂吗? 只是这里要考虑翻转后,数值…
[题目描述] 有一张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]即可 /*******…
[题目链接]:http://codeforces.com/contest/805/problem/D [题意] 给你一个字符串; 里面只包括a和b; 让你把里面的"ab"子串全都去掉; 方式是, 每次操作可以把"ab"替换成为"bba"; 直到整个字符串里面没有"ab"子串为止 [题解] 从ab开始 ab->bba 左边再加一个a的话 即aab 就相当于在bba左边加了一个a abba -> bbaba bbbba…
Balanced Number Problem Description A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the digit. When a pivot is placed at some…
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…
题意 给你一棵 \(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\…