A.

/*
It is found that each reversal or elimination will reduce a period of time 0
When 0 It can only be eliminated for a period of time
This is the way to judge */ #include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<set>
#include<map>
#define M 300010
#define ll long long using namespace std;
int read() {
int nm = , f = ;
char c = getchar();
for(; !isdigit(c); c = getchar()) if(c == '-') f = -;
for(; isdigit(c); c = getchar()) nm = nm * + c - '';
return nm * f;
}
ll n,x,y;
char s[M];
int main() {
n = read(), x = read(), y = read();
scanf("%s", s + );
int len = strlen(s + );
s[] = '?';
ll tot = ;
for(int i = ; i <= len; i++) if(s[i] != s[i - ] && s[i] == '') tot++;
if(tot == ) return puts("");
cout << min(tot * y, tot * x - x + y);
return ;
}

B.

/*
Maybe this kind of question is a table killer
There is no rule in the small data section Big data, regular // An obvious conclusion , If the total number is certain, we can find 1, 5, 10, 50 The number of different sums added up is equivalent to finding 0, 4, 9, 49 Of
Well, it's time to hit the clock
For the former 12 The data of Direct violence , The linear increase in the back   */ #include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<set>
#include<map>
#define M 30
#define ll long long using namespace std;
int read() {
int nm = , f = ;
char c = getchar();
for(; !isdigit(c); c = getchar()) if(c == '-') f = -;
for(; isdigit(c); c = getchar()) nm = nm * + c - '';
return nm * f;
}
const ll dx[]={,,,,,,,,,,,,,,,};
int main() {
ll n = read();
if(n <= ) cout << dx[n];
else cout << dx[] + (n - ) * ;
return ;
}

C.

Obviously, a line of the same color contributes the same to the answer in which line , So we can get the formula of inclusion and exclusion directly

/*
difficult Look at the solution */ #include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<set>
#include<map>
#define M 1231231
#define ll long long
const int mod = ;
using namespace std;
int read() {
int nm = , f = ;
char c = getchar();
for(; !isdigit(c); c = getchar()) if(c == '-') f = -;
for(; isdigit(c); c = getchar()) nm = nm * + c - '';
return nm * f;
}
ll poww(ll a, ll b) {
ll as = , tmp = a;
for(; b; b >>= , tmp = tmp * tmp % mod) if(b & ) as = as * tmp % mod;
return as;
}
ll c[M]; inline ll ni(ll a) {
return poww(a, mod - );
}
void shai(ll n) {
c[] = ;
for(int i = ; i <= n; i++) c[i] = c[i - ] * (n - i + ) % mod * ni(i) % mod;
}
int main() {
ll n = read();
ll ans = ;
shai(n);
for(int i = , j = ; i <= n; i++, j = -j) ans += j * c[i] % mod * poww(, (n - i) * n + i) % mod, ans %= mod;
ans = ans * % mod;
for(int i = , j = -; i < n; i++, j = -j) ans += 3ll * c[i] * j % mod * (poww(1ll - poww(, i), n) - poww(-1ll * poww(3ll, i), n)) % mod, ans %= mod;
cout << (ans + mod) % mod;
return ;
}

Codeforces Round #493 (Div. 1) More articles about

  1. Codeforces Round #493 (Div 2) (A~E)

    Catalog Codeforces 998 A.Balloons B.Cutting C.Convert to Ones D.Roman Digits E.Sky Full of Stars( A class Count ) C ...

  2. Cutting Codeforces Round #493 (Div. 2)

    Cutting There are a lot of things which could be cut — trees, paper, “the rope”. In this problem you ...

  3. Codeforces Round #493 (Div. 2)

    C - Convert to Ones To give you one 01 strand x Is the cost of inverting any substring y Is to take the opposite price for all substrings Ask all become 1 The minimum cost of Two possible A kind of handlebar 1 Put it all aside Then put the rest 0 become 1  Or take all of them ...

  4. Codeforces Round #493 (Div. 2)D. Roman Digits The first question is how to find the rules

    D. Roman Digits time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  5. 【Codeforces Round #493 (Div. 2) B】Cutting

    [ link ] I'm the link , Point me :) [ The question ] Enter the meaning here [ Answer key ] Obviously only in the front i It can be cut only when the number of odd and even positions is the same . ( And no matter how the front cuts , It can be cut here . So it's equivalent to having n Items , The cost of each item ...

  6. Codeforces Round #493 (Div. 2) A. Balloons Greedy for water

    Because it outputs any set of solutions , You can rank values from small to large , The first person chooses the first one , The second person chooses the rest . Then compare the elements selected by the first person with those selected by the second person to see if they are equal . Since the values of all elements have been ranked from small to large , This ensures that there will be ...

  7. Codeforces Round #493 (Div. 1) B. Roman Digits Beat the watch to find the rules

    The question : We're studying roman numbers . Roman numbers are only 4 Characters ,I,V,X,L Represent the 1,5,10,100. The value of a Roman numeral is the sum of the characters in the numeral , It has nothing to do with the order of the characters . for example XXXV=35,IXI=12. present ...

  8. Codeforces Round #493 (Div. 2) C. Convert to Ones fool around with _ structure _ Good question

    The question : Give you a length of nnn Of 010101 strand , You have two operations : 1. Flip a substring , cost XXX 2. Put... In a substring 0 become 1,1 become 0, cost YYY Please take this 01 It's all 1 The minimum cost of the string . ...

  9. Codeforces Round #493 (Div. 2) B. Cutting Prefixes and optimizations _ Moving back to water

    Don't explain , Title: over water Code: #include<cstdio> #include<cmath> #include<algorithm> using namespac ...

Random recommendation

  1. High performance network programming ( One )----accept Establishing a connection

    When writing a server , Many programmers are used to using high-level components . middleware ( for example OO( object-oriented ) Open source components encapsulated layer upon layer ), Compared to the efficiency of the server , They pay more attention to the efficiency of program development , The pursuit of faster completion of the project function point . Hope the application code doesn't matter at all ...

  2. ( translate 、 Continuous updating ) JavaScript It's a little bit of a trick ( One )

    Thank you for your good article , Also thanks to the authors who wrote these knowledge points and the authors who put them together . This is a github An article on , Here, I only do translation , Because my English level and programming ability are not so good , If there is something bad, please understand it ...

  3. .Net Interview 4 set

    One 1. What is the main idea of object-oriented ? answer : Inherit , polymorphic , encapsulation , class , object , Interface , Gather , polymerization , generalization 2. What is? ASP.net User control in answer : User control is to use .ascx File as extension , It will provide a variety of services ...

  4. understand Objective-C in NSAutoreleasePool Usage method

    The purpose of this article is to understand Objective-C in NSAutoreleasePool Usage method ,Objective-C Of Foundation A library is actually a runtime object system , And the general object language , for example C++,Java Different ...

  5. yii Use in active record Display the association

    model in : view in :

  6. Example018 Get focus when the home page loads

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. Create Detailed command

    mkdir: Create a directory /mkdir a b c : Create a peer Directory /mkdir -p aa/bb/cc: Create directory recursively touch: Modify file timestamp , Or create a new file that doesn't exist /-a Change access time /m ...

  8. How to achieve dede The article in the front page column specifies to call

    How to achieve dede The article in the front page column specifies to call , The column of the front page article is designated ID call dobote | Browse 11891 Time Recommended on 2016-05-20 10:53:26 The best answer {dede:arclist flag=' ...

  9. requestAnimationFrame end demo

  10. java serialize Talking about

    Serialization of objects (Serialization) One . The concept and purpose of serialization 1. What is serialization The lifetime of an object usually ends with the termination of the program that generated it . occasionally , You may need to save the state of the object , Restore objects when needed . We put ...