Educational Codeforces Round 8 ABCDE
来源:互联网 发布:中国解体知乎 编辑:程序博客网 时间:2024/05/12 08:14
套题链接:http://codeforces.com/contest/628
难度类型:前几题比较容易,D题后难度陡增。
A
题解
类型:模拟
根据题意一轮轮做就是了,只是题目有点长,要仔细读。
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <stack>#include <queue>#include <string>#include <vector>#include <set>#include <map>#define fi first#define se secondusing namespace std;typedef long long LL;typedef pair<int,int> PII;// headint get(int x) { for (int i = 31; ~i; i--) { if ((1<<i) & x) return (1<<i); }}int main() { int n, b, p; scanf("%d%d%d", &n, &b, &p); int ansb = 0, ansp = p * n; while (n > 1) { int x = get(n); ansb += b*x + x/2; n = x/2 + n - x; } printf("%d %d\n", ansb, ansp); return 0;}
B
题解
类型:dp,递推
需要注意是要连续的,然后就是进行一个线性的递推就行了。
dp数组的意义是以某位置为结尾,模4为几的个数。
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <stack>#include <queue>#include <string>#include <vector>#include <set>#include <map>#define fi first#define se secondusing namespace std;typedef long long LL;typedef pair<int,int> PII;// headconst int N = 3e5+5;const int mod = 4;char s[N];LL dp[2][mod];int main() { gets(s); int n = strlen(s); int cur = 1, pre = 0; LL ans = 0; for (int i = 0; i < n; i++) { int v = s[i] - '0'; for (int j = 0; j < mod; j++) { dp[cur][j] = 0; } for (int j = 0; j < mod; j++) { int nxt = (j * 10 + v) % mod; dp[cur][nxt] += dp[pre][j]; } dp[cur][v%mod]++; ans += dp[cur][0]; swap(cur, pre); } printf("%I64d\n", ans); return 0;}
C
题解
类型:贪心,模拟
要求变化距离的总和为某数,那尽量多去加,剩下的不变就行了。
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <stack>#include <queue>#include <string>#include <vector>#include <set>#include <map>#define fi first#define se secondusing namespace std;typedef long long LL;typedef pair<int,int> PII;// headconst int N = 1e5+5;char s[N];int main() { int n, k; scanf("%d%d%s", &n, &k, s); for (int i = 0; i < n && k; i++) { bool up = abs(s[i] - 'a') < abs(s[i] - 'z'); int mx = max(abs(s[i] - 'a'), abs(s[i] - 'z')); mx = min(mx, k); s[i] += up ? mx : -mx; k -= mx; } puts(k ? "-1" : s); return 0;}
D
题解
类型:数位dp
传送门:http://blog.csdn.net/xc19952007/article/details/50720986
E
题解
类型:数据结构,技巧
传送门:http://blog.csdn.net/xc19952007/article/details/50721057
0 0
- Educational Codeforces Round 8 ABCDE
- Codeforces Educational Round 5 ABCDE
- Educational Codeforces Round 7 ABCDE
- Codeforces Educational Round 12 655ABCDE
- Educational Codeforces Round 19 ABCDE题解
- Educational Codeforces Round 19 ABCDE题解
- Educational Codeforces Round 8
- Codeforces Round #364 ABCDE
- Educational Codeforces Round 8 总结
- Codeforces Beta Round #66 ABCDE
- Codeforces Round #369 (Div2) ABCDE
- Educational Codeforces Round 8 (A B C)
- Educational Codeforces Round 8-B. New Skateboard
- Educational Codeforces Round 1
- Educational Codeforces Round 2
- Educational Codeforces Round 2
- Educational Codeforces Round 2
- Educational Codeforces Round 3
- 关于mac电脑整个根目录文件夹都变成含有git分支的解决办法
- python爬虫(抓取百度图片)
- eclipse不同版本间区别
- CHECK_NRPE: Error - Could not complete SSL handshake.
- iOS UITabBarController封装
- Educational Codeforces Round 8 ABCDE
- lftp使用
- linux下的目录结构及重要目录文件含义知识
- poj2823Sliding Window【单调队列经典题】
- PullToRefreshView自动向下刷新
- registerClass
- sublime text 3 快捷键大全
- Unity 3D:在现有的Android游戏场景中显示AdMob的横幅
- 关于C++重定义问题