您的位置:首页 > 其它

Educational Codeforces Round 57 (Rated for Div. 2)

2018-12-29 14:16 1921 查看
版权声明:版权归Ordinarv所有 https://blog.csdn.net/ordinarv/article/details/85338044

A. Find Divisible

 

Description:

You are given a range of positive integers from lll to rrr.
Find such a pair of integers (x,y)(x, y)(x,y) that l≤x,y≤rl \le x, y \le rl≤x,y≤r, x≠yx \ne yx̸​=y and xxx divides yyy.
If there are multiple answers, print any of them.
You are also asked to answer TTT independent queries.

Input:

The first line contains a single integer TTT (1≤T≤10001 \le T \le 10001≤T≤1000) — the number of queries.
Each of the next TTT lines contains two integers lll and rrr (1≤l≤r≤9982443531 \le l \le r \le 9982443531≤l≤r≤998244353) — inclusive borders of the range.
It is guaranteed that testset only includes queries, which have at least one suitable pair.

Output:

Print TTT lines, each line should contain the answer — two integers xxx and yyy such that l≤x,y≤rl \le x, y \le rl≤x,y≤r, x≠yx \ne yx̸​=y and xxxdivides yyy. The answer in the iii-th line should correspond to the iii-th query from the input.
If there are multiple answers, print any of them.

Sample Input:

3
1 10
3 14
1 10

Sample Output:

1 7
3 9
5 10

题目链接

B. Substring Removal

Description:

You are given a string sss of length nnn consisting only of lowercase Latin letters.
A substring of a string is a contiguous subsequence of that string. So, string “forces” is substring of string “codeforces”, but string “coder” is not.
Your task is to calculate the number of ways to remove exactly one substring from this string in such a way that all remaining characters are equal (the number of distinct characters either zero or one).
It is guaranteed that there is at least two different characters in sss.
Note that you can remove the whole string and it is correct. Also note that you should remove at least one character.
Since the answer can be rather large (not very large though) print it modulo 998244353998244353998244353.
If you are Python programmer, consider using PyPy instead of Python when you submit your code.

Input:

The first line of the input contains one integer nnn (2≤n≤2⋅1052 \le n \le 2 \cdot 10^52≤n≤2⋅105) — the length of the string sss.
The second line of the input contains the string sss of length nnn consisting only of lowercase Latin letters.
It is guaranteed that there is at least two different characters in sss.

Output:

Print one integer — the number of ways modulo 998244353998244353998244353 to remove exactly one substring from sss in such way that all remaining characters are equal.

Sample Input:

4
abaa

Sample Output:

6

Sample Input:

7
aacdeee

Sample Output:

6

Sample Input:

2
az

Sample Output:

3

题目链接

试了一发模拟,果然TEL,than乘号写成减号 w3

[code]#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 2e5+5;
const int mod  = 998244353;
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
ll n;cin>>n;
ll ans = 3;
string s;cin>>s;
char pri;
//if(s[0] == s[1]) ans++;
//if(s[n-1] == s[n-2]) ans++;
int i,j;
int flag = 1;
for( i=1;i<n;i++){
if(s[i-1] == s[i]) ans++;
else
break;
}

for(j=n-2;j>=0;j--){
if(s[j+1] == s[j]) ans++;
else break;
}
ans = ans % mod;
char c;
if(s[0] == s[n-1]){
//if(i == j)
//	ans++;
ans= (ans + (i)*(n-j-1))%mod;
}

cout<<ans%mod<<endl;
return 0;
}

C. Polygon for the Angle

Description:

You are given an angle ang\text{ang}ang.
The Jury asks You to find such regular nnn-gon (regular polygon with nnn vertices) that it has three vertices aaa, bbband ccc (they can be non-consecutive) with ∠abc=ang\angle{abc} = \text{ang}∠abc=ang or report that there is no such nnn-gon.

If there are several answers, print the minimal one. It is guarantied that if answer exists then it doesn’t exceed 998244353998244353998244353.

Input:

The first line contains single integer TTT (1≤T≤1801 \le T \le 1801≤T≤180) — the number of queries.
Each of the next TTT lines contains one integer ang\text{ang}ang (1≤ang&lt;1801 \le \text{ang} &lt; 1801≤ang<180) — the angle measured in degrees.

Output:

For each query print single integer nnn (3≤n≤9982443533 \le n \le 9982443533≤n≤998244353) — minimal possible number of vertices in the regular nnn-gon or −1-1−1 if there is no such nnn.

Sample Input:

4
54
50
2
178

Sample Output:

10
18
90
180

题目链接

感谢ly大佬

忽略了一份不能整分,但是两份or三份有可能整分。debug后忘加上if判重又wa1发。

[code]#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 998244353;
int tab[185];
void init() {
int temp;
for(int i=3; i<=400; i++) {
//	temp = (i-2) * 180 / i / (i-2);
//if(180 % i) continue;
//temp = 180/i;
for(int j = i-2; j >0 ; j--) {
if((180*j) % i) continue;
temp = (j*180)/i;
if(!tab[temp]) tab[temp] = i;
}
}
//tab[179] = 360;
}
int main() {

int T;
init();
cin>>T;
while(T--) {
int n;
cin>>n;
cout<<tab
<<endl;
}
return 0;
}

D. Easy Problem

Description:

Vasya is preparing a contest, and now he has written a statement for an easy problem. The statement is a string of length nnn consisting of lowercase Latin latters. Vasya thinks that the statement can be considered hard if it contains a subsequence hard; otherwise the statement is easy. For example, hard, hzazrzd, haaaaard can be considered hard statements, while har, hart and drah are easy statements.
Vasya doesn’t want the statement to be hard. He may remove some characters from the statement in order to make it easy. But, of course, some parts of the statement can be crucial to understanding. Initially the ambiguity of the statement is 000, and removing iii-th character increases the ambiguity by aia_iai​ (the index of each char 3ff8 acter is considered as it was in the original statement, so, for example, if you delete character r from hard, and then character d, the index of d is still 444 even though you delete it from the string had).
Vasya wants to calculate the minimum ambiguity of the statement, if he removes some characters (possibly zero) so that the statement is easy. Help him to do it!
Recall that subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.

Input:

The first line contains one integer nnn (1≤n≤1051 \le n \le 10^51≤n≤105) — the length of the statement.
The second line contains one string sss of length nnn, consisting of lowercase Latin letters — the statement written by Vasya.
The third line contains nnn integers a1,a2,…,ana_1, a_2, \dots, a_na1​,a2​,…,an​ (1≤ai≤9982443531 \le a_i \le 9982443531≤ai​≤998244353).

Output:

Print minimum possible ambiguity of the statement after Vasya deletes some (possibly zero) characters so the resulting statement is easy.

Sample Input:

6
hhardh
3 2 9 11 7 1

Sample Output:

5

Sample Input:

8
hhzarwde
3 2 6 9 4 8 7 1

Sample Output:

4

Sample Input:

6
hhaarr
1 2 3 4 5 6

Sample Output:

0

题目链接

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: