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. Linq To Sql进阶系列(六)用object的动态查询与保存log篇

    动态的生成sql语句,根据不同的条件构造不同的where字句,是拼接sql 字符串的好处.而Linq的推出,是为了弥补编程中的 Data != Object 的问题.我们又该如何实现用object的动 ...

  2. Codeforces Round #422 (Div. 2) E. Liar 后缀数组+RMQ+DP

    E. Liar     The first semester ended. You know, after the end of the first semester the holidays beg ...

  3. CentOS7.2编译GCC7.3

    1.环境 本文使用VMWare虚拟机进行实验. 4 核CPU, 4GB 内存,20GB 硬盘,CentOS 7.2 最小安装(CentOS-7-x86_64-Minimal-1511.iso) 2.需 ...

  4. 数据结构之 图论---图的深度遍历( 输出dfs的先后遍历序列 )

    图的深度遍历 Time Limit: 1000MS Memory limit: 65536K 题目描述 请定一个无向图,顶点编号从0到n-1,用深度优先搜索(DFS),遍历并输出.遍历时,先遍历节点编 ...

  5. vue 做登陆页面 ( 登陆成功后去掉注册和登陆按钮 显示用户名)

    1.当登陆成功  显示用户名且去掉登陆和注册按钮 2.data里声明  后  就在登陆的方法里调用啦 下面说一下登陆的方法. 1.登陆的按钮代码在第一张图片里 2.登陆的弹出框 3.方法 ps:另一种 ...

  6. easyUI-右键菜单,关闭选项卡

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  7. zoj 3204 Connect them(最小生成树)

    题意:裸最小生成树,主要是要按照字典序. 思路:模板 prim: #include<iostream> #include<stdio.h> #include<string ...

  8. python startswith和endswith

    startswith判断文本是否以某个或某几个字符开始; endswith判断文本是否以某个或某几个字符结束; text = 'Happy National Day!' print text.star ...

  9. I.MX6 2014 u-boot 测试修改

    /************************************************************************* * I.MX6 2014 u-boot 测试修改 ...

  10. [POI 2007] 办公楼

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1098 [算法] 显然 , 答案为补图的连通分量个数 用链表优化BFS , 时间复杂度 ...