CF的rating设置改了。。人太多了,决定开小号打,果然是明智的选择!

水 A - Olesya and Rodion

#include <bits/stdc++.h>
using namespace std; typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f; int main(void) {
int n, t; scanf ("%d%d", &n, &t);
if (t == 10) {
if (n == 1) {
puts ("-1");
}
else {
for (int i=1; i<n; ++i) printf ("1");
puts ("0");
}
}
else {
for (int i=1; i<=n; ++i) {
printf ("%d", t);
}
puts ("");
} return 0;
}

组合数学 B - Kolya and Tanya

题意:有一个3n的圈,每个数字可以在[1, 3]中选择,问ai + ai+n + ai+2n != 6的方案数

分析:3n个点,每个点都有3种选择,而出现ai + ai+n + ai+2n != 6的组合有7种,i的位置有n种,所以答案就是:(3 ^ (3 * n) - 7 ^ (n) + MOD) % MOD

还好猜猜样例一次过掉,否则一旦卡住就不会出后面的两题了

#include <bits/stdc++.h>
using namespace std; typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7; int pow_mod(int x, int n, int p) {
int ret = 1;
while (n) {
if (n & 1) {
ret = 1ll * ret * x % p;
}
x = 1ll * x * x % p;
n >>= 1;
}
return ret;
} int main(void) {
int n; scanf ("%d", &n);
if (n == 1) {
printf ("20\n");
}
else
printf ("%d\n", (pow_mod (3, n * 3, MOD) - pow_mod (7, n, MOD) + MOD) % MOD); return 0;
}

  

构造 C - Marina and Vasya

题意:问是否有一个字符串和字符串a的不同个数与和字符串b的不同个数相同

分析:将a和b的字符比较,得到它们相同的个数以及不同的个数,不同的那块可以选择与它们都不同的或者与其中一个相同的,可以自由分配,相同的那块只能相同或都不同

#include <bits/stdc++.h>
using namespace std; typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
char s[N], t[N]; char f(char a, char b) {
if (a > b) swap (a, b);
char r = a + 1;
if (r == b) r++;
if (r > 'z') r = 'a';
return r;
} int main(void) {
int n, m; scanf ("%d%d", &n, &m);
scanf ("%s%s", s, t);
int dif = 0;
for (int i=0; i<n; ++i) {
if (s[i] != t[i]) dif++;
}
int low = dif / 2;
if (dif & 1) low++;
if (low > m) puts ("-1");
else {
if (m >= dif) {
int sam = m - dif;
for (int i=0; i<n; ++i) {
if (s[i] == t[i]) {
printf ("%c", sam > 0 ? f (s[i], t[i]) : s[i]);
sam--;
}
else {
printf ("%c", f (s[i], t[i]));
}
}
puts ("");
}
else {
int sam = (dif - m) * 2;
for (int i=0; i<n; ++i) {
if (s[i] == t[i]) {
printf ("%c", s[i]);
}
else {
if (sam <= 0) printf ("%c", f (s[i], t[i]));
else
printf ("%c", sam & 1 ? s[i] : t[i]);
sam--;
}
}
puts ("");
}
} return 0;
}

  

素数 D - Dima and Lisa

题意:略

分析:一个或两个很好想,三个没什么好办法,用哥德巴赫猜想,只能暴力来~

#include <bits/stdc++.h>
using namespace std; typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f; /*
素性测试,在小范围(1e5)内判素数个数以及单个数判素数有奇效,不适用于大范围判素数
*/
bool is_prime(int x) {
if (x == 2 || x == 3) return true;
if (x % 6 != 1 && x % 6 != 5) return false;
for (int i=5; i*i<=x; i+=6) {
if (x % i == 0 || x % (i + 2) == 0) return false;
}
return true;
} int main(void) {
int n; scanf ("%d", &n);
if (is_prime (n)) {
printf ("1\n%d\n", n);
}
else {
int x = n - 2;
if (is_prime (x)) {
printf ("2\n%d %d\n", 2, x);
}
else {
int k = n - 1;
while (true) {
if (is_prime (k)) break;
k--;
}
n -= k; //n >= 9
int a = n / 2;
while (a < n) {
if (is_prime (a) && is_prime (n - a)) {
printf ("3\n%d %d %d\n", k, a, n - a); return 0;
}
a++;
}
}
} return 0;
}

  

Codeforces Round #324 (Div. 2)的更多相关文章

  1. Codeforces Round #324 (Div. 2)解题报告

    ---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...

  2. Codeforces Round #324 (Div. 2) C (二分)

    题目链接:http://codeforces.com/contest/734/problem/C 题意: 玩一个游戏,一开始升一级需要t秒时间,现在有a, b两种魔法,两种魔法分别有m1, m2种效果 ...

  3. Codeforces Round #324 (Div. 2) E. Anton and Ira 贪心

    E. Anton and Ira Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...

  4. Codeforces Round #324 (Div. 2) D. Dima and Lisa 哥德巴赫猜想

    D. Dima and Lisa Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...

  5. Codeforces Round #324 (Div. 2) C. Marina and Vasya 贪心

    C. Marina and Vasya Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/pr ...

  6. Codeforces Round #324 (Div. 2) B. Kolya and Tanya 快速幂

    B. Kolya and Tanya Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/pro ...

  7. Codeforces Round #324 (Div. 2) A. Olesya and Rodion 水题

    A. Olesya and Rodion Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/p ...

  8. Codeforces Round #324 (Div. 2) (哥德巴赫猜想)

    题目:http://codeforces.com/problemset/problem/584/D 思路: 关于偶数的哥德巴赫猜想:任一大于2的偶数都可写成两个素数之和. 关于奇数的哥德巴赫猜想:任一 ...

  9. Codeforces Round #324 (Div. 2) Dima and Lisa 哥德巴赫猜想

    原题链接:http://codeforces.com/contest/584/problem/D 题意: 给你一个奇数,让你寻找三个以内素数,使得和为这个奇数. 题解: 这题嘛...瞎比搞搞就好,首先 ...

  10. Codeforces Round #324 (Div. 2) Marina and Vasya 乱搞推理

    原题链接:http://codeforces.com/contest/584/problem/C 题意: 定义$f(s1,s2)$为$s1,s2$不同的字母的个数.现在让你构造一个串$s3$,使得$f ...

随机推荐

  1. hiho1079 线段树区间改动离散化

    题目链接: hihocoder1079 代码: #include<iostream> #include<cstdio> #include<cstring> #inc ...

  2. Android SDK更新失败的解决方案(原创)

    笔者在搭建好Android环境后,进行Android的SDK更新下载升级,乌龟的速度,更让人生气的是到了85%的进度时,直接timeout,循环3次无果.查阅相关资料,原来是Google的服务器遭遇了 ...

  3. STM32唯一身份识别ID(器件电子签名)的读取以及芯片Flash大小读取

    每个STM32有一个独立的ID,这个ID可以用来: 产品唯一的身份标识的作用:    ●  用来作为序列号(例如USB字符序列号或者其他的终端应用):    ●  用来作为密码,在编写闪存时,将此唯一 ...

  4. button在firefox 和 ie 下的问题

    最近做了一个关于数据库管理的项目,因为不用考虑ie9以下的兼容性,所以一股脑的写完啦,到测试的时候发现了一个bug IE和火狐下有个模块关闭按钮的hover没有反应,ie不行就算了,火狐怎么也不行?我 ...

  5. 新建web项目时css注意事项

    初始化css ,如设置body的margin,padding值,button:hover的pointer手型,li dd的list-style,a的下划线等. 最好将常用的初始化css文件整合在一起, ...

  6. html5--6-63 布局

    html5--6-63 布局 实例 学习要点 掌握传统布局与CSS3新增布局方式的实现和应用 掌握CSS3新增属性box-sizing 了解CSS3新增的多列布局 常用布局方式 固定布局与流体布局的优 ...

  7. maven实战(2)-- m2eclipse插件配置

    使用eclipse进行maven项目的开发,需要安装m2eclipse插件.下面介绍该插件的配置,插件的安装在此不作介绍. 配置m2eclipse 先决条件:已安装maven,m2eclipse 以上 ...

  8. 机器学习 Hidden Markov Models 2

    Hidden Markov Models 下面我们给出Hidden Markov Models(HMM)的定义,一个HMM包含以下几个要素: ∏=(πi)表示初始状态的向量.A={aij}状态转换矩阵 ...

  9. [Selenium] The most commonly used CSSSelector

    CSSSelector Example Description element.element div.dropdown Select all  <div> elements whose ...

  10. MFC之document与view实践总结

    Document/View是MFC的基石,负责程序数据的管理和显示,Doculent和Viewd的关系有一档一视,一档多视和多档多视,下面将分别对实现过程中的重点知识进行总结. 1. 视图的同步更新 ...