地址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 = , INF = 1e9 + ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N, ans = ;
char s[MAXN];
main() {
#ifdef WIN32
freopen("a.in", "r", stdin);
#endif
N = read();
for(int i = ; i <= N; i++) {
scanf("%s", s + );
int L = strlen(s + );
for(int j = ; j <= L - ; j++) {
if((s[j] == 'c' && s[j + ] == 'h')||
(s[j] == 'h' && s[j + ] == 'e')||
(s[j] == 'e' && s[j + ] == '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 + , INF = 1e9 + ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N, K, ans = ;
int a[MAXN];
main() {
#ifdef WIN32
freopen("a.in", "r", stdin);
#endif
int T = read();
while(T--) {
N = read(); K = read();
int sum = , ans = ;
for(int i = ; i <= N; i++) a[i] = read(), sum += a[i];
for(int i = ; 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 + , INF = 1e9 + ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
main() {
#ifdef WIN32
freopen("a.in", "r", stdin);
#endif
int N = read();
while(N--) {
int A = read(), B = read(), C = read();
int ans = abs( * B - A - C);
if(ans & ) printf("%lld\n", ans / + );
else printf("%lld\n", ans / );
}
}

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 + , INF = 1e9 + ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int a[MAXN];
char ans[MAXN];
main() {
#ifdef WIN32
freopen("a.in", "r", stdin);
#endif
int T = read();
while(T--) {
int N = read(), sum = ;
for(int i = ; i <= N; i++) a[i] = read(), sum += a[i];
for(int i = ; i <= N; i++) {
if(sum % i != ) {ans[i] = ''; continue;}
int cur = , num = ;
for(int j = ; j <= N; j++) {
cur += a[j];
if(cur == sum / i) cur = ;
else if(cur > sum / i) {ans[i] = ''; break;}
}
ans[i] = (cur == ? '' : '');
}
for(int i = ; i <= N; i++)
putchar(ans[i]);
puts("");
}
}

D

CodeChef March Lunchtime 2018 div2的更多相关文章

  1. 【启发式搜索】Codechef March Cook-Off 2018. Maximum Tree Path

    有点像计蒜之道里的 京东的物流路径 题目描述 给定一棵 N 个节点的树,每个节点有一个正整数权值.记节点 i 的权值为 Ai.考虑节点 u 和 v 之间的一条简单路径,记 dist(u, v) 为其长 ...

  2. Codechef March Cook-Off 2018. Maximum Tree Path

    目录 题意 解析 AC_code @(Codechef March Cook-Off 2018. Maximum Tree Path) 题意 给你一颗\(n(1e5)\)个点有边权有点权的树,\(Mi ...

  3. Codechef October Challenge 2018 游记

    Codechef October Challenge 2018 游记 CHSERVE - Chef and Serves 题目大意: 乒乓球比赛中,双方每累计得两分就会交换一次发球权. 不过,大厨和小 ...

  4. Codechef September Challenge 2018 游记

    Codechef September Challenge 2018 游记 Magician versus Chef 题目大意: 有一排\(n(n\le10^5)\)个格子,一开始硬币在第\(x\)个格 ...

  5. 「Codechef April Lunchtime 2015」Palindromeness

    「Codechef April Lunchtime 2015」Palindromeness 解题思路 : 考虑对于回文子串 \(s\) 贡献的定义: \[ value_s = [\ s[1,\lflo ...

  6. Codechef March Challenge 2014——The Street

    The Street Problem Code: STREETTA https://www.codechef.com/problems/STREETTA Submit Tweet All submis ...

  7. codechef February Challenge 2018 简要题解

    比赛链接:https://www.codechef.com/FEB18,题面和提交记录是公开的,这里就不再贴了 Chef And His Characters 模拟题 Chef And The Pat ...

  8. Codechef STMINCUT S-T Mincut (CodeChef May Challenge 2018) kruskal

    原文链接http://www.cnblogs.com/zhouzhendong/p/9010945.html 题目传送门 - Codechef STMINCUT 题意 在一个有边权的无向图中,我们定义 ...

  9. codechef January Lunchtime 2017简要题解

    题目地址https://www.codechef.com/LTIME44 Nothing in Common 签到题,随便写个求暴力交集就行了 Sealing up 完全背包算出得到长度≥x的最小花费 ...

随机推荐

  1. MySQL数据库(2)----检索信息

    SELECT 语句的简化语法如下: SELECT what to retrive FROM table or tables WHERE conditions that data must satisf ...

  2. Linux系统搭建GitLab---阿里云Centos7搭建Gitlab踩坑

    一.简介 GitLab,是一个利用 Ruby on Rails 开发的开源应用程序,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目安装. 它拥有与GitHub类似的功能,能 ...

  3. Selenium_Python接口-Alert类

    Alert类的路径:from selenium.webdriver.common.alert import Alert Alert类主要是一些对弹出框的操作,如:获取属性.确认.取消等 接口内容: f ...

  4. 面试准备之一Python

    基本数据类型 函数 模块与包 面向对象 网络编程 垃圾回收机制 G 并发编程

  5. springmvc中配置RESTful风格控制器

    一般的http请求中其实只需要get和post就可以满足项目需求了,而为什么还要使用restful可能就是为了使请求url看起来更加直观,好看吧.. restful常用的请求方式:get,post,p ...

  6. sql语句浅谈以及mysql遇到的问题解决见解

    mysql数据库基本操作: .显示数据库和查看mysql版本 show databases; select version(); select user();查看用户 .选择数据库 use 数据库名; ...

  7. springMVC+mybatis事务管理总结

    1.spring,mybatis事务管理配置与@Transactional注解使用: 概述事务管理对于企业应用来说是至关重要的,即使出现异常情况,它也可以保证数据的一致性.Spring Framewo ...

  8. 第六周 day6 python学习笔记

    1.Python面向对象编程OOP(Object Oriented Programming) 封装:可以隐藏实现细节,使代码模块化 继承:可以扩展已存在的代码模块,可以使代码实现重用 多态:一种接口, ...

  9. 在Clion里链接gtest

    本来以为像之前链接boost一样,加个链接路径就好了,没想到报找不到gtest的符号,搞了半天,没弄明白啥原因. 网上也没搜到好方法,只能把gtest的源码加到项目里,然后在链接了. CMake配置如 ...

  10. ASN.1详解

    Chapter 4 ASN.1 4.1 网络数据表示及编码4.2 ASN.1的基本概念4.3 基本编码规则 4.1 网络数据表示及编码ASN.1(Abstract Syntax Notation 1) ...