A.

  1. /*
  2. 发现每次反转或者消除都会减少一段0
  3. 当0只有一段时只能消除
  4. 这样判断一下就行
  5.  
  6. */
  7.  
  8. #include<cstdio>
  9. #include<algorithm>
  10. #include<cstring>
  11. #include<iostream>
  12. #include<set>
  13. #include<map>
  14. #define M 300010
  15. #define ll long long
  16.  
  17. using namespace std;
  18. int read() {
  19. int nm = , f = ;
  20. char c = getchar();
  21. for(; !isdigit(c); c = getchar()) if(c == '-') f = -;
  22. for(; isdigit(c); c = getchar()) nm = nm * + c - '';
  23. return nm * f;
  24. }
  25. ll n,x,y;
  26. char s[M];
  27. int main() {
  28. n = read(), x = read(), y = read();
  29. scanf("%s", s + );
  30. int len = strlen(s + );
  31. s[] = '?';
  32. ll tot = ;
  33. for(int i = ; i <= len; i++) if(s[i] != s[i - ] && s[i] == '') tot++;
  34. if(tot == ) return puts("");
  35. cout << min(tot * y, tot * x - x + y);
  36. return ;
  37. }

B.

  1. /*
  2. 可能这种题是打表克星
  3. 小数据部分没有规律 数据大了有规律
  4.  
  5. //一个显然的结论 ,如果数字总数确定的话我们求 1, 5, 10, 50 加起来的不同和的个数相当于求0, 4, 9, 49 的
  6. 好吧打打表就出来了
  7. 对于前12的数据 直接暴力 ,后面的线性增加 
  8.  
  9. */
  10.  
  11. #include<cstdio>
  12. #include<algorithm>
  13. #include<cstring>
  14. #include<iostream>
  15. #include<set>
  16. #include<map>
  17. #define M 30
  18. #define ll long long
  19.  
  20. using namespace std;
  21. int read() {
  22. int nm = , f = ;
  23. char c = getchar();
  24. for(; !isdigit(c); c = getchar()) if(c == '-') f = -;
  25. for(; isdigit(c); c = getchar()) nm = nm * + c - '';
  26. return nm * f;
  27. }
  28. const ll dx[]={,,,,,,,,,,,,,,,};
  29. int main() {
  30. ll n = read();
  31. if(n <= ) cout << dx[n];
  32. else cout << dx[] + (n - ) * ;
  33. return ;
  34. }

C.

显然同色的一行在哪一行对答案贡献是一样的,于是我们可以直接得出容斥的式子

  1. /*
  2. difficult 看题解啦
  3.  
  4. */
  5.  
  6. #include<cstdio>
  7. #include<algorithm>
  8. #include<cstring>
  9. #include<iostream>
  10. #include<set>
  11. #include<map>
  12. #define M 1231231
  13. #define ll long long
  14. const int mod = ;
  15. using namespace std;
  16. int read() {
  17. int nm = , f = ;
  18. char c = getchar();
  19. for(; !isdigit(c); c = getchar()) if(c == '-') f = -;
  20. for(; isdigit(c); c = getchar()) nm = nm * + c - '';
  21. return nm * f;
  22. }
  23. ll poww(ll a, ll b) {
  24. ll as = , tmp = a;
  25. for(; b; b >>= , tmp = tmp * tmp % mod) if(b & ) as = as * tmp % mod;
  26. return as;
  27. }
  28. ll c[M];
  29.  
  30. inline ll ni(ll a) {
  31. return poww(a, mod - );
  32. }
  33. void shai(ll n) {
  34. c[] = ;
  35. for(int i = ; i <= n; i++) c[i] = c[i - ] * (n - i + ) % mod * ni(i) % mod;
  36. }
  37. int main() {
  38. ll n = read();
  39. ll ans = ;
  40. shai(n);
  41. for(int i = , j = ; i <= n; i++, j = -j) ans += j * c[i] % mod * poww(, (n - i) * n + i) % mod, ans %= mod;
  42. ans = ans * % mod;
  43. 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;
  44. cout << (ans + mod) % mod;
  45. return ;
  46. }

Codeforces Round #493 (Div. 1)的更多相关文章

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

    目录 Codeforces 998 A.Balloons B.Cutting C.Convert to Ones D.Roman Digits E.Sky Full of Stars(容斥 计数) 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 给你一个01串 x是反转任意子串的代价 y是将子串全部取相反的代价 问全部变成1的最小代价 两种可能 一种把1全部放到一边 然后把剩下的0变成1  要么把所有的 ...

  4. Codeforces Round #493 (Div. 2)D. Roman Digits 第一道打表找规律题目

    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

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然只有在前i个位置奇数偶数出现次数都相同的地方才能切. (且不管前面怎么切,这里都能切的. 那么就相当于有n个物品,每个物品的代价 ...

  6. Codeforces Round #493 (Div. 2) A. Balloons 贪心水题

    由于是输出任意一组解,可以将价值从小到大进行排序,第一个人只选第一个,第二个人选其余的.再比较一下第一个人选的元素和第二个人所选元素和是否相等即可.由于已将所有元素价值从小到大排过序,这样可以保证在有 ...

  7. Codeforces Round #493 (Div. 1) B. Roman Digits 打表找规律

    题意: 我们在研究罗马数字.罗马数字只有4个字符,I,V,X,L分别代表1,5,10,100.一个罗马数字的值为该数字包含的字符代表数字的和,而与字符的顺序无关.例如XXXV=35,IXI=12. 现 ...

  8. Codeforces Round #493 (Div. 2) C. Convert to Ones 乱搞_构造_好题

    题意: 给你一个长度为 nnn 的 010101串 ,你有两种操作: 1.将一个子串翻转,花费 XXX 2.将一个子串中的0变成1,1变成0,花费 YYY 求你将这个01串变成全是1的串的最少花费. ...

  9. Codeforces Round #493 (Div. 2) B. Cutting 前缀和优化_动归水题

    不解释,题目过水 Code: #include<cstdio> #include<cmath> #include<algorithm> using namespac ...

随机推荐

  1. STL 的 vector 根据元素的值来删除元素的方法

    vector 的 erase( ) 只能删除迭代器,所以要想删某种值的元素,需要这样: 假设有一个 vector 叫 vt ,则 vt.erase( remove( vt.begin() , vt.e ...

  2. app崩溃后自动重启

    android 引用:http://blog.csdn.net/caiwenfeng_for_23/article/details/41184353 package com.tan.abnormalr ...

  3. java实现文件的上传和下载

    1. servlet 如何实现文件的上传和下载? 1.1上传文件 参考自:http://blog.csdn.net/hzc543806053/article/details/7524491 通过前台选 ...

  4. Git-.gitignore配置

    .gitignore文件配置:keil工程文件类型模板 # reference to Keil->help->µVision User's Guide->Appendix->B ...

  5. IK分词器的使用

    1.下载 根据自己的版本进行下载 https://github.com/medcl/elasticsearch-analysis-ik/releases wget https://github.com ...

  6. Winfrom窗体无法关闭问题--检查是否存在重写

    问题描述: Winfrom窗体无法关闭问题----点击关闭/最大/最小化无法正常相应. 问题来源: 老版本的程序要求使用无边框的Form窗体(实现功能——设置为无边框窗体并重写窗体的关闭.最大.最小化 ...

  7. ui选型

    基本思路是风格必须适合博客风格,必须独树一帜. 选中的ui框架必须符合上述两个条件,另外,如果需要自身做一些css修改,修改量必须尽可能小. 1) 不用bootstrap的自带ui.bootstrap ...

  8. Paramiko&堡垒机

    Paramiko paramiko模块,基于SSH用于连接远程服务器并执行相关操作. 一.安装 pip install paramiko 二.使用 SSHClient 用于连接远程服务器并执行基本命令 ...

  9. Springboot监控之一:SpringBoot四大神器之Actuator之2--覆盖修改spring cloud的默认的consul健康检查规则

    微服务网关是socket长连接与支付公司对接,该网关需要提供http接口给内部系统调用,当socket没有建立连接时(网关服务的高可用是haProxy搭建的,有些服务的socket可能未连上支付公司) ...

  10. python programming作业5

      # -*- coding: utf-8 -*- class ageError(Exception): pass class salaryError(Exception): pass class s ...