A. Combination Lock time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there…
题目链接: http://codeforces.com/contest/606/problem/D D. Lazy Student time limit per test2 secondsmemory limit per test256 megabytes 问题描述 Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange…
Illegal spices 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1995 Description Jabba: Han, my boy, you disappoint me. Why haven't you paid me? And why did you fry poor Greedo? Han: Look, Jabba, next time you wanna talk to me, come see me yourself…
E. Intellectual Inquiry 题目连接: http://www.codeforces.com/contest/655/problem/E Description After getting kicked out of her reporting job for not knowing the alphabet, Bessie has decided to attend school at the Fillet and Eggs Eater Academy. She has be…
B. Lucky Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain…
D. Bear and Two Paths time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two dist…
C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ...…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4319 如果字符集有 5e5 那么大的话,挨个填上去就行了.但只有26个字符,所以要贪心地尽量填和上一次一样的字符. 按 sa[ ] 的顺序从小到大填字符,判断这个位置 x 能否填上一次在 y 填的字符的条件就是 rk[ x+1 ] > rk[ y+1 ]. 因为 x 的字典序比 y 大,而 x 位置要填和 y 一样的字符,所以 x 的后面应该比 y 大.发现后面部分也是两个后缀,所以利用“…
题意:给定一个序列,让你经过不超过9的6次方次操作,变成一个有序的,操作只有在一个连续区间,交换前一半和后一半. 析:这是一个构造题,我们可以对第 i 个位置找 i 在哪,假设 i 在pos 位置,那么如果 (pos-i)*2+i-1 <= n,那么可以操作一次换过来, 如果不行再换一种,如果他们之间元素是偶数,那么交换 i - pos,如果是奇数,交换 i - pos+1,然后再经过一次就可以换到指定位置. 代码如下: #pragma comment(linker, "/STACK:1…
题意:给你一串长度为\(n\)的序列,有的位置被锁上了,你可以对没锁的位置上的元素任意排序,使得最后一个\(\le0\)的前缀和的位置最小,求重新排序后的序列. 题解:贪心,将所有能动的位置从大到小排个序就行了. 代码: struct misaka{ int a; int loc; }e[N]; int t; int n; int main() { //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); t=read(); while(t--)…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4726 题意:给出两个n位的数字,均无前缀0.重新排列两个数字中的各个数,重新排列后也无前缀0.得到的两个新数相加和最大.这里的相加是无进位的相加.输出结果.输出时不要输出前缀0. 思路:答案的第一位比较特殊,相加的两个数中不能有0.可以枚举这个答案中的第一个数字,查找是否存在两个数相加为这个数字.后面的道理一样,也是枚举. int a[2][10]; int n; char s[2][N]; int…