CCPC 2017-2018, Finals Solution
A - Dogs and Cages
水。
#include <bits/stdc++.h>
using namespace std; int t;
double n; int main()
{
scanf("%d", &t);
for (int kase = ; kase <= t; ++kase)
{
scanf("%lf", &n);
printf("Case #%d: %.10f\n", kase, n - );
}
return ;
}
B - Same Digit
留坑。
C - Rich Game
题意:有两个人,A可以控制输赢,但是没有钱,B有无限的钱,他们打羽毛球,至少要获得11个点并且要比对方至少多获得两个点才能赢下当局,如果A 赢了 一个点,A要给B Y元,否则 B 给A X 元 求他们一共打K局的情况下,A最多可以赢多少局
思路:显然,当x > y 的时候 可以赢k局
考虑 x <= y 的情况 根据贪心的思路,假设A 要输 t 局
那么 必然要满足 $11yt >= (k - t)(11y - 9x)$
#include <bits/stdc++.h>
using namespace std; int t, x, y, k; int main()
{
scanf("%d", &t);
for (int kase = ; kase <= t; ++kase)
{
printf("Case #%d: ", kase);
scanf("%d%d%d", &x, &y, &k);
if (x > y) printf("%d\n", k);
else
{
int t = (int)ceil(k * ( * y - * x) * 1.0 / ( * y + * x));
printf("%d\n", k - t);
}
}
return ;
}
D - Mr. Panda and Circles
留坑。
E - Evil Forest
水。
#include <bits/stdc++.h>
using namespace std; #define N 1010 int t, n, sum, num; int main()
{
scanf("%d", &t);
for (int kase = ; kase <= t; ++kase)
{
scanf("%d", &n); sum = ;
for (int i = ; i <= n; ++i)
{
scanf("%d", &num);
sum += num;
sum += (num % ) ? (num / ) + : (num / );
}
printf("Case #%d: %d\n", kase, sum);
}
return ;
}
F - Fair Lottery
留坑。
G - Alice’s Stamps
题意:给出M个区间,选择K个区间,使得选择的元素尽量多,区间可以交叉
思路:$dp[i][j]$ 表示 第i位,选择k个区间的时候,数量最多是多少
三个状态转移
$dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])$
$dp[i][j +1] = max(dp[i][j], dp[i][j + 1])$
$dp[i + cnt][j + 1] = max(dp[i + cnt][j], dp[i][j] + cnt)$
cnt 为 那个区间最长能到哪里
#include<bits/stdc++.h>
using namespace std;
#define N 2010
int dp[N][N];
struct node{
int l, r;
inline node(){}
inline node(int l, int r) :l(l), r(r){}
inline bool operator < (const node &b) const
{
return l == b.l ? r > b.r : l < b.l;
}
}arr[N];
int n, m, k;
int cnt, val;
int main()
{
int t;
scanf("%d",&t);
for(int cas = ; cas <= t; ++cas)
{
scanf("%d %d %d" , &n, &m, &k);
for(int i = ; i <= m; ++i)
{
scanf("%d %d", &arr[i].l, &arr[i].r);
}
sort(arr + , arr + + m);
memset(dp, , sizeof dp);
val = ;
cnt = ;
for(int i = ; i < n; ++i)
{
while(cnt <= m && arr[cnt].l == i + )
{
val = max(val, arr[cnt].r - arr[cnt].l + );
cnt++;
}
for(int j = ; j <= k; ++j)
{
dp[i + ][j] = max(dp[i + ][j], dp[i][j]);
dp[i][j + ] = max(dp[i][j], dp[i][j + ]);
dp[i + val][j + ] = max(dp[i + val][j + ], dp[i][j] + val);
}
if(val) --val;
}
printf("Case #%d: %d\n", cas, dp[n][k]);
}
return ;
}
H - Equidistance
留坑。
I - Inkopolis
留坑。
J - Subway Chasing
留坑。
K - Knightmare
题意:在无限大的棋盘上,马走日,有多少个点是能够走到的
思路:BFS找规律,二阶差分
#include <bits/stdc++.h>
using namespace std; #define ull unsigned long long int arr[] = {, , , , , , }; int t;
ull n; int main()
{
scanf("%d", &t);
for (int kase = ; kase <= t; ++kase)
{
printf("Case #%d: ", kase);
scanf("%llu", &n);
if (n <= ) printf("%d\n", arr[n]);
else
{
ull sum = ; n -= ;
sum += (ull) * n + (ull) * n * (n + );
printf("%llu\n", sum);
}
}
return ;
}
CCPC 2017-2018, Finals Solution的更多相关文章
- MyEclips 2017/2018 (mac 版)安装与破解
MyEclips 2017/2018 (mac 版)安装与破解 现在在学J2EE,然后使用的工具就是 MyEclipse,现在就抛弃 Eclipse 了,我就不多说它俩的区别了,但是 MyEclips ...
- MyEclipse 2017/2018 安装与破解 图文教程
SSM 框架-02-MyEclipse 2017/2018 安装与破解 现在在学J2EE,然后使用的工具就是 MyEclipse,现在就抛弃 Eclipse 了,我就不多说它俩的区别了,但是 MyEc ...
- </2017><2018>
>>> Blog 随笔原始文档及源代码 -> github: https://github.com/StackLike/Python_Note >>> 统计信 ...
- CCPC 2016-2017, Finals Solution
A - The Third Cup is Free 水. #include<bits/stdc++.h> using namespace std; ; int n; int arr[max ...
- 我的2017&2018
最近项目进入验收阶段,所以上班没那么忙碌了,但是怎么说呢,我可能天生是闲不住的主,觉得浑身不自在(我这样的人是不是特别不会享福),此处应该有个笑脸哈. 翻看了博客园好几个大牛写的技术文章,感慨大牛不愧 ...
- [2017 - 2018 ACL] 对话系统论文研究点整理
(论文编号及摘要见 [2017 ACL] 对话系统. [2018 ACL Long] 对话系统. 论文标题[]中最后的数字表示截止2019.1.21 google被引次数) 1. Domain Ada ...
- CorelDRAW X7 X8 2017 2018是什么关系?
从CorelDRAW 2017版本开始我们叫习惯了的X几系列的CorelDRAW毅然决然的就换了称呼,所以有时候很多朋友对于软件版本,经常会傻傻分不清,还有人认为X8版本比2017版本高,究竟为什么会 ...
- JetBrains 2017/2018全系列产品激活工具
可谓是工欲善其事,必先利其器,相信作为优秀开发工程师的你都想拥有一套快捷高效的编码工具,而JetBrains这家公司的产品,不管是那种编程语言,其开发工具确实让开发者们着迷,JetBrains的产品博 ...
- 2018-2019 ACM-ICPC, Asia East Continent Finals Solution
D. Deja vu of … Go Players 签. #include <bits/stdc++.h> using namespace std; int t, n, m; int m ...
随机推荐
- Linux mii-tool 命令
mii-tool 用来查看或设置网卡的相关参数,该命令已经过时了,推荐使用 ethtool 命令 [root@localhost ~]$ mii-tool -v eth1 # 查看网卡的相关信息,包括 ...
- thinkjs——两表联查
问题来源: 现有一张texture以及一张tradename表,两者的联系是texture表中有一字段名为tid对应tradename表中的id,而tradename表中却有一字段type,要求根据t ...
- 跳表 SkipList
跳表是平衡树的一种替代的数据结构,和红黑树不同,跳表对树的平衡的实现是基于一种随机化的算法,这样就使得跳表的插入和删除的工作比较简单. 跳表是一种复杂的链表,在简单链表的节点信息之上又增加了额 ...
- cursor:hand & cursor:pointer
1.cursor:hand & cursor:pointer都是将鼠标设置为手形. 2.cursor:hand存在兼容性问题,firefox并不支持该属性值.但大部分主流浏览器支持cursor ...
- 【BZOJ4545】DQS的trie 后缀自动机+LCT
[BZOJ4545]DQS的trie Description DQS的自家阳台上种着一棵颗粒饱满.颜色纯正的trie. DQS的trie非常的奇特,它初始有n0个节点,n0-1条边,每条边上有一个字符 ...
- [SQL] SQL 修复命令
You should run the repair from the original installation media, using the following command line ...
- centos6.5安装sendmail
1.下载安装sendEmail(下载绿色版,解压可直接使用) wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1. ...
- 线段树(成段更新,区间求和lazy操作 )
hdu1556 Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- 青岛网络赛J-Press the button【暴力】
Press the Button Time Limit: 1 Second Memory Limit: 131072 KB BaoBao and DreamGrid are playing ...
- Magento 2 初探
进入公司有一小段时间了,虽然自己之前一直从事前端工作,但是基本工作就是做一些国内电商网站的前端工作.在刚进入这家公司时,自己对 magento2 一无所知,尽管上班前看过老大发给我的一些文档资料,但是 ...