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. 图像处理之基础---ffmpeg 中的图像缩放

    http://blog.csdn.net/bweaglegao/article/details/8540860 http://www.cnblogs.com/acloud/archive/2011/1 ...

  2. python day- 5 字典(dic)的 增删改查 及 操作方法

    字典(dic) 1.定义及格式 用{ }大括号括起来的,由key:value 来保存数据的就是 字典(dic) eg:dic = {"及时雨" : "宋江" , ...

  3. 网页Html代码优化及分析

  4. RSA前端JS加密,后端JAVA解密实现

    用RSA非对称加密方式实现.后台生成rsa密钥对,然后在页面设置rsa公钥,提交时用公钥加密密码,生成的密文传到后台,后台再用私钥解密,获取密码明文.这样客户端只需要知道rsa加密方式和公钥,前台不知 ...

  5. RFC外部断点在在SAP退出后会失效

    rfc外部断点系统退出后会删除吗?  不会删除Rfc外部断点在在SAP退出后标识还在, 但是断点会失效! 附 断点消息: ABAP 中的断点分为静态和动态两种.一. 静态断点(Static Break ...

  6. (linux)mmccard驱动的读写过程解析

      mmc io的读写从mmc_queue_thread()的获取queue里面的request开始. 先列出调用栈,看下大概的调用顺序, 下面的内容主要阐述这些函数如何工作. host->op ...

  7. WAS:节点不同步问题

    刀片服务器硬盘坏了,换了硬盘后,通过dmgr无法重启该节点上的server. 单机./starServer 后,服务虽然启动了,但后台一直提示如下: [-- ::: CST] RoleViewLead ...

  8. 转:Oracle客户端NLS_LANG参数的设置详解

    原文:http://database.51cto.com/art/201107/279361.htm 我们知道,Oracle客户端语言支持可以通过NLS_LANG参数的设置来完成,不同的系统平台上NL ...

  9. 怎么往mac中finder个人收藏里添加文件夹

    1.打开Finder,点击左上角finder偏好设置 2.选择边栏 3.如果侧栏中没有的文件夹,直接长按文件夹直接拖入.

  10. LibSVM学习详细说明

    代码文件主要针对Matlab进行说明,但个人仍觉得讲解的支持向量机内容非常棒,可以做为理解这一统计方法的辅助资料; LibSVM是台湾林智仁(Chih-Jen Lin)教授2001年开发的一套支持向量 ...