AtCoder Grand Contest 030 Solution
A - Poisonous Cookies
签到。
#include <bits/stdc++.h>
using namespace std; #define ll long long
ll a, b, c; int main()
{
while (scanf("%lld%lld%lld", &a, &b, &c) != EOF)
{
if (c <= a + b + ) printf("%lld\n", b + c);
else printf("%lld\n", a + b + b + );
}
return ;
}
B - Tree Burning
Unsolved.
题意:
在一个环上,长度为L, 刚开始在0点,有些点上有树
每次可以顺时针走或者逆时针走,每碰到一棵树这棵树就消失
然后可以又选择方向去走,直到所有树都消失,求最长路径
C - Coloring Torus
Upsolved.
题意:
要求构造一个$n \cdot n的矩形,使得每个点都被染色,且只能用k种颜色,并且k种颜色都要有$
思路:
如果k是4的倍数,那么有一个显然的做法
比如说8
1 2 3 4
5 6 7 8
1 2 3 4
5 6 7 8
这样排下去,n取 k / 2
但是如果k不是4的倍数,我们可以通过移位,使得它合理
$当r = 0 \;mod\; 2的时候,x = (r + c) \;\; mod\;\; n$
$否则 x = n + (r + c) % n$
注意如果x大于k,要减去n
为什么这样是对的呢,不知道。。。不会证(逃
#include <bits/stdc++.h>
using namespace std; int main()
{
int k;
while (scanf("%d", &k) != EOF)
{
if (k <= )
{
printf("%d\n", k);
for (int i = ; i <= k; ++i) for (int j = ; j <= k; ++j)
printf("%d%c", i, " \n"[j == k]);
}
else
{
int n = (k + ) / * ;
printf("%d\n", n);
for (int i = ; i <= n; ++i) for (int j = ; j <= n; ++j)
{
int x;
if (i & ) x = (i + j) % n;
else x = n + (i + j) % n;
if (x >= k) x -= n;
printf("%d%c", x + , " \n"[j == n]);
}
}
}
return ;
}
D - Inversion Sum
Unsolved.
题意:
给出一个序列,给出$q个x_i, y_i$ 每次有两种可能的操作
1° 交换$x_i, y_i位置上的数$
2° 什么也不做
这样一共有$2^q次可能的序列 求所有可能序列的逆序数$
AtCoder Grand Contest 030 Solution的更多相关文章
- AtCoder Grand Contest 030题解
第一次套刷AtCoder 体验良好 传送门 Poisonous Cookies cout<<b+min(c,a+b+); Tree Burning 难度跨度有点大啊 可以证明当第一次转向之 ...
- Atcoder Grand Contest 030 F - Permutation and Minimum(DP)
洛谷题面传送门 & Atcoder 题面传送门 12 天以前做的题了,到现在才补/yun 做了一晚上+一早上终于 AC 了,写篇题解纪念一下 首先考虑如果全是 \(-1\) 怎么处理.由于我 ...
- AtCoder Grand Contest 030 (AGC030) C - Coloring Torus 构造
原文链接https://www.cnblogs.com/zhouzhendong/p/AGC030C.html 题解 才发现当时是被题意杀了. 当时理解的题意是“对于任意的 (i,j) ,颜色 i 和 ...
- AtCoder Grand Contest 030 自闭记
A:阅读. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> ...
- AtCoder Grand Contest 029 Solution
A: Solved. 签. #include <bits/stdc++.h> using namespace std; #define ll long long #define N 200 ...
- Coloring Torus(Atcoder Grand Contest 030 C)
怎么外国都喜欢考脑筋急转弯…… 题意 输入 $k$,要求构造一个 $n\times n$ 的矩阵($n$ 自选),使得恰好用 $k$ 中颜色把每个点都染色,并且同一种颜色的格子周围 相邻的每种颜色数量 ...
- AtCoder Grand Contest 030 (AGC030) F - Permutation and Minimum 动态规划
原文链接www.cnblogs.com/zhouzhendong/p/AGC030F.html 草率题解 对于每两个相邻位置,把他们拿出来. 如果这两个相邻位置都有确定的值,那么不管他. 然后把所有的 ...
- AtCoder Grand Contest 031 简要题解
AtCoder Grand Contest 031 Atcoder A - Colorful Subsequence description 求\(s\)中本质不同子序列的个数模\(10^9+7\). ...
- AtCoder Grand Contest 012
AtCoder Grand Contest 012 A - AtCoder Group Contest 翻译 有\(3n\)个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大 ...
随机推荐
- Mac下,如何把Github上的仓库删除掉
这个虽然简单,但是还是做个记录,当初也是找不到地方,最终还是去百度了,步骤很简单: 如下: 1.进入Github主页,选中你要删除的仓库,点击进入到如下页面:
- swift - UISlider 的用法
swift的UISlider的用法和oc基本没有区别 1.创建 class SecondViewController: UIViewController { var slider = UISlider ...
- (使用lua++)Lua脚本和C++交互(四)
上一篇中,你已经可以在Lua里面用C++的函数了,那么咱们再增加一点难度,比如,我有一个CTest对象,要作为一个参数,传输给func_Add()执行,怎么办?很简单,如果你对上面的代码仔细阅读,你会 ...
- 开始iOS 7中自动布局教程(一)
本文转载至 http://www.cocoachina.com/industry/20131203/7462.html 到目前为止,如果你的设计相当的复杂,那么你必须编写大量的代码来适应这样的布局.你 ...
- List转换为数组Array的方法
List<String> list = new ArrayList<String>(); list.add("str1"); list.add(" ...
- PHP MySQL Insert Into
INSERT INTO 语句用于向数据库表中插入新记录. 向数据库表插入数据 INSERT INTO 语句用于向数据库表添加新记录. 语法 INSERT INTO table_name VALUES ...
- 《转》python学习--基础下
转自http://www.cnblogs.com/BeginMan/archive/2013/04/12/3016323.html 一.数字 在看<Python 核心编程>的时候,我就有点 ...
- Dell、IBM服务器配置远程管理卡
author: headsen chen date: 2018-10-09 14:12:32 1,IBM的服务器: 需要在bios里边进行配置,具体配置如下: , 开机画面过完之后,按F1进入bio ...
- sort排序和uniq统计命令
author:headsen chen date: 2018-08-13 11:08:09 1,sort:排序的功能,默认安装ASCII码来排序,-n 安装数值排,-r 按照倒序来排 [root@b ...
- This function has none of DETERMINISTIC, NO SQL
错误信息: [Err] 1418 - This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declara ...