【解题报告】AtCoder ABC115 (附英文题目)
------------------------------迟到的AK----------------------------------
A - Christmas Eve Eve Eve
Time limit : 2sec / Memory limit : 1024MB
Score : 100 points
Problem Statement
In some other world, today is December D-th.
Write a program that prints Christmas
if D=25, Christmas Eve
if D=24, Christmas Eve Eve
if D=23 and Christmas Eve Eve Eve
if D=22.
Constraints
- 22≤D≤25
- D is an integer.
签到题1,考察if语句的用法。。。
#include <iostream>
int main()
{
int n; std::cin >> n;
if (n == ) puts("Christmas");
if (n == ) puts("Christmas Eve");
if (n == ) puts("Christmas Eve Eve");
if (n == ) puts("Christmas Eve Eve Eve");
return ;
}
B - Christmas Eve Eve
Time limit : 2sec / Memory limit : 1024MB
Score : 200 points
Problem Statement
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1≤i≤N) is pi yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N−1 items cost their regular prices. What is the total amount he will pay?
Constraints
- 2≤N≤10
- 100≤pi≤10000
- pi is an even number.
签到题2,考察for语句的用法。。。
#include <iostream>
int main()
{
int n, x, si = , mi = -; std::cin >> n;
for (int i = ; i <= n; ++i)
std::cin >> x, si += x, mi = std::max(mi, x);
std::cout << si - (mi >> );
return ;
}
C - Christmas Eve
Time limit時間制限 : 2sec / Memory limitメモリ制限 : 1024MB
Score : 300 points
Problem Statement
In some other world, today is Christmas Eve.
There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1≤i≤N) is hi meters.
He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.
More specifically, let the height of the tallest decorated tree be hmax meters, and the height of the shortest decorated tree be hmin meters. The smaller the value hmax−hmin is, the better. What is the minimum possible value of hmax−hmin?
Constraints
- 2≤K<N≤105
- 1≤hi≤109
- hi is an integer.
签到题3,考察sort函数的用法。。。
#include <iostream>
#include <algorithm>
int h[];
int main()
{
int n, mi = 2e9 + , k; std::cin >> n >> k;
for (int i = ; i <= n; ++i) std::cin >> h[i];
std::sort(h + , h + n + );
for (int i = k; i <= n; ++i) mi = std::min(mi, h[i] - h[i - k + ]);
std::cout << mi;
return ;
}
D - Christmas
Time limit時間制限 : 2sec / Memory limitメモリ制限 : 1024MB
Score : 400 points
Problem Statement
In some other world, today is Christmas.
Mr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:
- A level-0 burger is a patty.
- A level-L burger (L≥1) is a bun, a level-(L−1) burger, a patty, another level-(L−1) burger and another bun, stacked vertically in this order from the bottom.
For example, a level-1 burger and a level-2 burger look like BPPPB
and BBPPPBPBPPPBB
(rotated 90 degrees), where B
and P
stands for a bun and a patty.
The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?
Constraints
- 1≤N≤50
- 1≤X≤( the total number of layers in a level-N burger )
- N and X are integers.
#include <iostream>
#include <algorithm> long long b[], h[], n, r, ans; void solve(int now)
{
if (r <= ) return;
if (!now) { --r, ++ans; return; }
if (r >= h[now]) { r -= h[now], ans += b[now]; return; }
--r; if (r > ) solve(now - );
if (r > ) ++ans, --r;
--r; if (r > ) solve(now - );
} int main()
{
scanf("%lld%lld", &n, &r);
h[] = , b[] = ;
for (int i = ; i <= ; ++i) h[i] = (h[i - ] << ) + , b[i] = + (b[i - ] << );
solve(n); std::cout << ans;
return ;
}
太简单辣。。。。。。。。
【解题报告】AtCoder ABC115 (附英文题目)的更多相关文章
- 习题:codevs 1035 火车停留解题报告
本蒟蒻又来写解题报告了.这次的题目是codevs 1035 火车停留. 题目大意就是给m个火车的到达时间.停留时间和车载货物的价值,车站有n个车道,而火车停留一次车站就会从车载货物价值中获得1%的利润 ...
- Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告
Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...
- HDU 4869 Turn the pokers (2014多校联合训练第一场1009) 解题报告(维护区间 + 组合数)
Turn the pokers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- LeetCode :1.两数之和 解题报告及算法优化思路
最近开始重拾算法,在 LeetCode上刷题.顺便也记录下解题报告以及优化思路. 题目链接:1.两数之和 题意 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 ...
- Tarjan算法求解桥和边双连通分量(附POJ 3352 Road Construction解题报告)
http://blog.csdn.net/geniusluzh/article/details/6619575 在说Tarjan算法解决桥和边双连通分量问题之前我们先来回顾一下Tarjan算法是如何 ...
- 【九度OJ】题目1026:又一版 A+B 解题报告
[九度OJ]题目1026:又一版 A+B 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1026 题目描述: 输入两个不超过 ...
- 【九度OJ】题目1124:Digital Roots 解题报告
[九度OJ]题目1124:Digital Roots 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1124 题目描述: T ...
- 【九度OJ】题目1074:对称平方数 解题报告
[九度OJ]题目1074:对称平方数 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1074 题目描述: 打印所有不超过n( ...
- 【九度OJ】题目1064:反序数 解题报告
[九度OJ]题目1064:反序数 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1064 题目描述: 设N是一个四位数,它的 ...
随机推荐
- hive与hbase关联
进入hbase: hbase shell 进入HIVE: hive hbase中建一张t_student_info表,添加两个列族 create 't_student_info','st1','st2 ...
- Python+Selenium----处理登录图片验证码
1.说明 在做自动化测试的时候,经常会遇到登录,其中比较麻烦的就是验证码的处理,现在比较常用的图形验证码,每次刷新,得到的验证码不一致,所以,一般来说,获取验证码图片有两种方式: (1)拿到验证码的图 ...
- Tree and Queries CodeForces - 375D 树上莫队
http://codeforces.com/problemset/problem/375/D 树莫队就是把树用dfs序变成线性的数组. (原数组要根据dfs的顺序来变化) 然后和莫队一样的区间询问. ...
- Linux Shell命令系列(4)
16. cat命令 “cat”代表了连结(Concatenation),连接两个或者更多文本文件或者以标准输出形式打印文件的内容. 17. cp 命令 “copy”就是复制.它会从一个地方复制一个文件 ...
- HBase基础讲解
HBase定义 HBase 是一个高可靠.高性能.面向列.可伸缩的分布式存储系统,利用Hbase技术可在廉价PC Server上搭建 大规模结构化存储集群. HBase 是 ...
- SpringBoot | 第十四章:基于Docker的简单部署
前言 讲解了单元测试,本章节讲讲应用的部署吧.总体而言,在进行自动化部署时,基本都会用上Jenkins+Maven+Docker进行部署.本章节主要讲解使用Maven+Docker进行SpringBo ...
- 用weex create 创建app项目 报 ERROR in index.web.js from UglifyJs 错误!
用weex create创建一个APP项目,安装依赖后运行报 这个是package.json index.web.js 在dist目录下是build时生成的. 上面的答案没有给大家细节,不好意思致歉下 ...
- jQuery中$(function(){})与(function($){})(jQuery)、$(document).ready(function(){})等的区别讲解
1.(function($){...})(jQuery); (1).原理: 这实际上是匿名函数,如下: function(arg){...} 这就定义了一个匿名函数,参数为arg:而调用函 ...
- python使用浮点类型float计算后,数值不对_20180827
在练习时,输入如下代码: 结果不准确. 原因:https://blog.csdn.net/bitcarmanlee/article/details/51179572 浮点数一个普遍的问题就是在计算机的 ...
- mybatis-关联关系2
关系关系主要有一对一,一对多,多对多,往往多对多都是通过俩个一对多来完成的 实例项目还是之前的,只是增加了一个年级实体类 1.创建年级实体类:---年级中有学生的集合 package com.java ...