CodeChef March Lunchtime 2018 div2
地址https://www.codechef.com/LTIME58B?order=desc&sortBy=successful_submissions
简单做了一下,前三题比较水,第四题应该算是经典题
AChef and Friends
直接暴力枚举即可
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int MAXN = 1001, INF = 1e9 + 10; inline int read() {char c = getchar(); int x = 0, f = 1;while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();return x * f; } int N, ans = 0; char s[MAXN]; main() { #ifdef WIN32freopen("a.in", "r", stdin); #endifN = read();for(int i = 1; i <= N; i++) {scanf("%s", s + 1);int L = strlen(s + 1);for(int j = 1; j <= L - 1; j++) {if((s[j] == 'c' && s[j + 1] == 'h')||(s[j] == 'h' && s[j + 1] == 'e')||(s[j] == 'e' && s[j + 1] == 'f')){ans++; break;}}}printf("%d", ans); }
A
BMagic Elements
维护一个所有元素的和,直接模拟即可
#include<cstdio> #include<cstring> #include<algorithm> #define int long long using namespace std; const int MAXN = 1e6 + 10, INF = 1e9 + 10; inline int read() {char c = getchar(); int x = 0, f = 1;while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();return x * f; } int N, K, ans = 0; int a[MAXN]; main() { #ifdef WIN32freopen("a.in", "r", stdin); #endifint T = read();while(T--) {N = read(); K = read();int sum = 0, ans = 0;for(int i = 1; i <= N; i++) a[i] = read(), sum += a[i];for(int i = 1; i <= N; i++) if(a[i] + K > sum - a[i])ans++;printf("%d\n", ans);} }
B
CThree Integers
把式子化成$2B = A +C$的形式,不难看出改B一定是最优的。
特判一下奇偶性即可
#include<cstdio> #include<cstring> #include<algorithm> #define int long long using namespace std; const int MAXN = 1e6 + 10, INF = 1e9 + 10; inline int read() {char c = getchar(); int x = 0, f = 1;while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();return x * f; } main() { #ifdef WIN32freopen("a.in", "r", stdin); #endifint N = read();while(N--) {int A = read(), B = read(), C = read();int ans = abs(2 * B - A - C);if(ans & 1) printf("%lld\n", ans / 2 + 1);else printf("%lld\n", ans / 2);} }
C
DPartitions
个人感觉是一道比较好的题
设所有元素的和为$sum$
不难发现,不论如何分,分成的段数一定是$sum$的因子
而且不论如何分,第一段一定是$1-x$(以$1$为起点)
这样我们遇到一个因子就枚举一边序列暴力分割就可以
这题TM居然卡常
#include<cstdio> #include<cstring> #include<algorithm> #define int long long using namespace std; const int MAXN = 1e6 + 10, INF = 1e9 + 10; inline int read() {char c = getchar(); int x = 0, f = 1;while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();return x * f; } int a[MAXN]; char ans[MAXN]; main() { #ifdef WIN32freopen("a.in", "r", stdin); #endifint T = read();while(T--) {int N = read(), sum = 0;for(int i = 1; i <= N; i++) a[i] = read(), sum += a[i];for(int i = 1; i <= N; i++) {if(sum % i != 0) {ans[i] = '0'; continue;}int cur = 0, num = 0;for(int j = 1; j <= N; j++) {cur += a[j];if(cur == sum / i) cur = 0;else if(cur > sum / i) {ans[i] = '0'; break;}}ans[i] = (cur == 0 ? '1' : '0');}for(int i = 1; i <= N; i++) putchar(ans[i]);puts("");} }
D
CodeChef March Lunchtime 2018 div2相关推荐
- Codechef July Challenge 2018 : Subway Ride
传送门 首先(想了很久之后)注意到一个性质:同一条边有多种颜色的话保留3种就可以了,这是因为假如最优解要求当前位置与相邻两条边都不相同,那么只要有3条边,就肯定可以满足这一点. 完事就做一个nlogn ...
- Codechef Coders’Legacy 2018 CLSUMG Sum of Primes
Description 设 f(x)f(x) 表示把 xx 拆分成两个质数之和的方案数. 例如 f(10)=2f(10)=2 , 因为 10=3+7=5+510=3+7=5+5 TT 次询问,每次给出 ...
- 【线段树 泰勒展开】Codechef April Challenge 2018 Chef at the Food Fair
第一次写泰勒展开:本地和CC差距好大 题目大意 大厨住的城市里办了一场美食节.一条街上开设了$N$个摊位,编号为$1∼N$.这天开始时,第$i$个摊位的食物会导致食物中毒的概率是$P_i$.在这一天中 ...
- Codechef January Challenge 2018 - Killjee and k-th letter
题意: 给出一个的串 s,将 s 所有子串按照字典序排列好相接起来形成一个新串q次询问,每一次询问问新串中的第 k 个字符是什么,强制在线. $|s|,q \le 2*10^{5} $ 跟所有子串有关 ...
- Codechef August Challenge 2018 : Coordinate Compression
传送门 外边二分,里面拿线段树维护贪心就行了. #include<cstdio> #include<vector> #include<cstring> #inclu ...
- php cve 2017 12933,18-017 (March 27, 2018)
描述 * indicates a new version of an existing rule Deep Packet Inspection Rules: DCERPC Services - Cli ...
- CodeChef March Challenge 2017 题解
CC XENTASK 由于要交替选,所以要不第一个人选位置为奇数的数,第二个人选位置为偶数的数,要不第一个人选位置为偶数的数,第二个人选位置为奇数的数.取最小值即可. #include <cst ...
- 2018/03/25
2019独角兽企业重金招聘Python工程师标准>>> March 25 2018 Sunday Weather:cloudy 1.需求: a=0.5 b=3 c=a*b 求c的值: ...
- 2018中国计算机所有相关会议,2018年计算机视觉顶会和人工智能顶级会议时间表...
一 计算机视觉顶级会议时间表html 1. IEEE Conference on Computer Vision and Pattern Recognition (CVPR 2018)mvc * Lo ...
最新文章
- AI人工智能天机芯芯片
- os和sys模块的常用方法
- 24点——判断4个数能否经过运算使得结果为24
- 食品行业ERP选型 需把握关键的20%
- Java:数列排序 给定一个长度为n的数列,将这个数列按从小到大的顺序排列。1<=n<=200
- 54.施工方案第二季(最小生成树)
- 非常干货之Python资源大全
- 共享锁与排它锁区别(转)
- java 物联网 eclipse_Eclipse物联网
- 2009 managertool software download..........
- 字节面试:如何用Redis实现一个分布式锁?
- android 键盘修改回车键监听及无效处理,imeOptions无效处理
- Clickhouse查询语句 sample
- where in 和where=
- uni-app报错 cid unmatched at view.umd.min.js:1解决方案
- 【最新排名(按点赞)】投票倒计时三天:继续为你喜欢的征文作品投票吧!...
- Java基于JSP的论坛交流系统
- Moving.............
- Oracle时代:Sun开源拳头产品迎不同未来
- 环洋市场调研-2021年全球企业估值服务行业调研及趋势分析报告
热门文章
- Workspace in use or cannot be created, choose a different one.--错误解决办法
- 【android】EGL数据结构
- OpenCV中cvAdds和cvAdd中的mask的用法探讨
- 系列(四)—Http协议
- 关于redis的keys命令的性能问题
- (二)Docker中以redis.conf配置文件启动Redis
- 队列与环形队列使用数组模拟
- FLutter入门:异步加载组件FutureBuilder
- 一文搞懂RSA算法原理及简单实现
- resource.arsc二进制内容解析 之 Dynamic package reference