AtCoder Beginner Contest 115 Solution
Solved.
#include <bits/stdc++.h>
using namespace std; int main()
{
int n; while (scanf("%d", &n) != EOF)
{
printf("Christmas");
int need = - (n - );
for (int i = need; i; --i) printf(" Eve");
puts("");
}
return ;
}
Solved.
#include <bits/stdc++.h>
using namespace std; int main()
{
int n;
while (scanf("%d", &n) != EOF)
{
int res = , Max = ;
for (int i = , p; i <= n; ++i)
{
scanf("%d", &p);
res += p;
Max = max(Max, p);
}
printf("%d\n", res - Max / );
}
return ;
}
Solved.
#include <bits/stdc++.h>
using namespace std; #define N 100010
int n, k, h[N]; int main()
{
while (scanf("%d%d", &n, &k) != EOF)
{
for (int i = ; i<= n; ++i) scanf("%d", h + i);
sort(h + , h + + n, [](int a, int b) { return a > b; });
int res = 1e9;
for (int i = ; i + k - <= n; ++i) res = min(res, h[i] - h[i + k - ]);
printf("%d\n", res);
}
return ;
}
Solved.
题意:
递归定义了一个汉堡,显然它是对称的,求从一端吃掉它长度L,吃掉多少patty
思路:
显然,汉堡的长度和拥有patty的个数都是可以线性递推的,先预处理
然后按区间递归下去求答案即可。
#include <bits/stdc++.h>
using namespace std; #define ll long long
#define N 110
int n; ll x;
ll len[N], tot[N];
ll res; void DFS(ll l, ll r, int cur)
{
//printf("%lld %lld %d\n", l, r, cur);
if (cur < || l > x) return;
if (r <= x)
{
res += tot[cur];
return;
}
ll mid = (l + r) >> ;
if (mid <= x) ++res;
DFS(l + , mid - , cur - );
DFS(mid + , r - , cur - );
} int main()
{
len[] = ;
for (int i = ; i <= ; ++i)
len[i] = * len[i - ] + ;
tot[] = ;
for (int i = ; i <= ; ++i)
tot[i] = * tot[i - ] + ;
while (scanf("%d%lld", &n, &x) != EOF)
{
res = ;
DFS(, len[n], n);
printf("%lld\n", res);
}
return ;
}
AtCoder Beginner Contest 115 Solution的更多相关文章
- AtCoder Beginner Contest 115 题解
题目链接:https://abc115.contest.atcoder.jp/ A Christmas Eve Eve Eve 题目: Time limit : 2sec / Memory limit ...
- AtCoder Beginner Contest 131 Solution
前言 这次ABC还是有一点难度的吧. TaskA Security Solution 直接模拟就好了. Code /* mail: mleautomaton@foxmail.com author: M ...
- Atcoder Beginner Contest 115 D Christmas 模拟,递归 B
D - Christmas Time limit : 2sec / Memory limit : 1024MB Score : 400 points Problem Statement In some ...
- AtCoder Beginner Contest 114 Solution
A 753 Solved. #include <bits/stdc++.h> using namespace std; ]; int main() { mp[] = mp[] = mp[] ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 068 ABCD题
A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...
- AtCoder Beginner Contest 154 题解
人生第一场 AtCoder,纪念一下 话说年后的 AtCoder 比赛怎么这么少啊(大雾 AtCoder Beginner Contest 154 题解 A - Remaining Balls We ...
- AtCoder Beginner Contest 238 A - F 题解
AtCoder Beginner Contest 238 \(A - F\) 题解 A - Exponential or Quadratic 题意 判断 \(2^n > n^2\)是否成立? S ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
随机推荐
- Java架构学习 转(Spring+SpringMVC+MyBatis+easyUI)
Spring+SpringMVC+MyBatis+easyUI : http://www.cnblogs.com/han-1034683568/p/6730869.html
- python2.0 s12 day3
s12 day3 视频每节的内容 03 python s12 day3 本节内容概要 第三天的主要内容 上节没讲完的: 6.集合 7.collections 1)计数器 2)有序字典 3)默认字典 4 ...
- 【RF库Collections测试】Get Dictionary Values
Name:Get Dictionary ValuesSource:Collections <test library>Arguments:[ dictionary ]Returns val ...
- Spring new对象时注解失效
新建了一个新类(A)后,在类中用注解将属性注入.类名(A)上用 @Component ,类中的一个属性(name)上用 @Autowired或@Resource, 方法(fun)中通过 属性(name ...
- Python MySQLdb 模块
MySQLdb 是 Python2 连接 MySQL 的一个模块,常见用法如下: [root@localhost ~]$ yum install -y MySQL-python # 安装 MySQLd ...
- C语言简介(转自菜鸟教程)
C 简介 C 语言是一种通用的高级语言,最初是由丹尼斯·里奇在贝尔实验室为开发 UNIX 操作系统而设计的.C 语言最开始是于 1972 年在 DEC PDP-11 计算机上被首次实现. 在 1978 ...
- 【markdown】使用 js 实现自己得markdown 网页编辑器
首先从这里下载其浏览器版: https://github.com/evilstreak/markdown-js/releases 解压缩后在其js文件同目录下新建一个网页进行测试,代码如下: < ...
- linux 学习的一些书单,对了解android 也有大用
要推荐的书,我在<那两年炼就的Android内功修养>这篇文章中有提到,这里再列一下出来: 语言类: <深度探索C++对象模型>,对应的英文版是<Inside C+++ ...
- 【BZOJ4545】DQS的trie 后缀自动机+LCT
[BZOJ4545]DQS的trie Description DQS的自家阳台上种着一棵颗粒饱满.颜色纯正的trie. DQS的trie非常的奇特,它初始有n0个节点,n0-1条边,每条边上有一个字符 ...
- javaWeb项目springMVC框架下利用ITextpdf 工具打印PDF文件的方法(打印表单、插入图片)
方法一:打印PDF表单以及在PDF中加入图片 需要的资料: jar包:iTextAsian.jar ,itext-2.1.7.jar: 源码: public static void main(Stri ...