算法杂题(思维、模拟)
题目链接
@[toc]
A - やめて嘘はあなたらしくないよ
The
-index of an author is the largest where he has at least papers with citations not less than .
Bobo has published many papers.
Givenwhich means Bobo has published papers with citations exactly , find the -index of Bobo.
Input
The input consists of several test cases and is terminated by end-of-file.
The first line of each test case contains an integer.
The second line containsintegers .
Output
For each test case, print an integer which denotes the result.
Constraint
The sum ofdoes not exceed .
Sample Input1
1 2
2
1 2 3
3
0 0 0 0
Sample Output1
2
0
1 |
|
B - 目を見てこれからのことを話そう
The
-index of an author is the largest where he has at least hh papers with citations not less than .
Bobo has no papers and he is going to publish some subsequently.
If he works on a paper for xx hours, the paper will getcitations, where is a known constant.
It’s clear thatshould be a positive integer.
There is also a trick — one can cite his own papers published earlier.
Given Bobo hasworking hours, find the maximum -index of him.
Input
The input consists of several test cases and is terminated by end-of-file.
Each test case contains two integersand .
Output
For each test case, print an integer which denotes the maximum-index.
Constraint
The number of test cases does not exceed.
Sample Input
3 0
3 1
1000000000 1000000000
Sample Output
1
2
1000000000
Hint
For the first sample, Bobo can workpapers for hour each.
With the trick mentioned, he will get papers with citations. Thus, his -index is .
For the second sample, Bobo can workpapers for and hours respectively. He will get papers with citations . Thus, his -index is 。
最优解是每个论文都花1小时。仔细想一想就出来了。
1 |
|
F - my wish かなえたいのに
Bobo has
tuples .
He would like to find the lexicographically smallest permutation
of.
such that for
it holds thatInput
The input consists of several test cases and is terminated by end-of-file. The first line of each test case contains an integer.
Theof the following nn lines contains 3 integers and .
Output
For each test case, print nn integersseperated by spaces. DO NOT print trailing spaces.
Constraint
The sum of nn does not exceed 10^4
Sample Input
2
1 1 1
1 1 2
2
1 1 2
1 1 1
3
1 3 1
2 2 1
3 1 1
Sample Output
2 1
1 2
1 2 3
除法化乘法避免精度损失,在优化一下乘法(卡long long上限)。
1 |
|
G - すべては God knows…
Bobo has a string S=s1s2…sn consists of letter
a
,b
andc
.
He can transform the string by inserting or deleting substringsaa
,bb
andabab
.
Formally, A=u∘w∘v (`∘'' denotes string concatenation) can be transformed into A′=u∘v and vice versa where u, v are (possibly empty) strings and w∈{
aa,
bb,
abab}. Given the target string $T=t_1t_2\cdots t_m$, determine if Bobo can transform the string S into T. Input The input consists of several test cases and is terminated by end-of-file. The first line of each test case contains a string $s_1s_2\cdots s_n$. The second line contains a string $t_1t_2\cdots t_m$. Output For each test case, print
Yesif Bobo can. Print
Nootherwise. Constraint $1≤n,m≤10^4$ $s_1,s_2,\cdots ,s_n,t_1,t_2,\cdots ,t_m∈\{a,b,c\}$ The sum of n and m does not exceed 250,000. Sample Input ab ba ac ca a ab Sample Output Yes No No Hint For the first sample, Bobo can transform as
ab => aababb => babb => ba`.
根据提示,ab可以转为ba,ba同理。且可以增加删除aa或bb,那么,在没有c的字符串中,只要统计两个字符串中a和b个数是否同奇同偶即可。而对于c,可以看作c将字符串分割成了若干子串。
1 |
|
K - 傷跡なぞる
Given
find out the number of pairs of integers where and is a multiple of 2018.
Input
The input consists of several test cases and is terminated by end-of-file.
Each test case contains four integers.
Output
For each test case, print an integer which denotes the result.
Constraint
The number of tests cases does not exceed.
Sample Input
1 2 1 2018
1 2018 1 2018
1 1000000000 1 1000000000
Sample Output
3
6051
1485883320325200
2018的公约数只有1*2018以及2*1009这两对,根据容斥定理很容易求出结果。
1 |
|