CF633(div.2)A. Filling Diamonds】的更多相关文章

题目描述 http://codeforces.com/contest/1339/problem/A 给定一个 \(n(1\le n \le 10^9)\) ,问用一个由两个三角形组成的菱形,填充下面这种图形有多少种不同的填法. 解题 通过枚举发现,被填充图形中竖着的菱形区域正好是 \(n\) 个. 而且在任何一种填充方式中,只能同时存在一个竖着的菱形填充,其余的填充必须是横向的菱形. 选取不同的竖向菱形区块填充,最终也都只能得到一种不同的填充方式. 所以填充方式数目 \(ans = n\) .…
链接: https://codeforces.com/contest/1182/problem/A 题意: You have a given integer n. Find the number of ways to fill all 3×n tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap. This pict…
链接: https://codeforces.com/contest/1228/problem/B 题意: Suppose there is a h×w grid consisting of empty or full cells. Let's make some definitions: ri is the number of consecutive full cells connected to the left side in the i-th row (1≤i≤h). In partic…
题目描述 http://codeforces.com/contest/1339/problem/B 有一个长度为 \(n(3\le n \le 10^5)\) 的整数序列 \(a_1,a_2,...,a_n(-10^9\le a_i\le 10^9)\) . 将序列重排序使得 \(|a_1-a_2|\le|a_2-a_3|\le...\le|a_{n-1}-a_n|\) . 输出任意一种满足上述条件的排序方式. 解题 这里采用一种类似贪心的策略: 序列 \(a\) 中的最大值与最小值差的绝对值(…
题目描述 http://codeforces.com/contest/1339/problem/C 给定一个长度为 \(n\) 的无序数组,你可以在第 \(x\) 秒进行一次下面的操作. 从数组选取任意个数字(也可以一个都不选),为他们全部都加上 \(2^{x-1}\) . 询问你最少可以用多少秒,使得数组非降序排列. 解题 最快策略 首先简化一下问题,假设操作变成:第 \(x\) 秒,可以选取任意个数字,为他们全部都加上 \(1\) .分析一下在这个条件下,可以达到最少秒数的策略. 假设我们有…
题意:问有多少种组合方法让每一行每一列最小值都是1 思路:我们可以以行为转移的状态 附加一维限制还有多少列最小值大于1 这样我们就可以不重不漏的按照状态转移 但是复杂度确实不大行(减了两个常数卡过去的...) #include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double eps = 1e-6; const int N = 3e5+7; typedef long long ll; co…
Codeforces Round #633(Div.2) \(A.Filling\ Diamonds\) 答案就是构成的六边形数量+1 //#pragma GCC optimize("O3") //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/stdc++.h> using namespace std; function<void(void)> __…
Codeforces Round #566 (Div. 2) A Filling Shapes 给定一个 \(3\times n\) 的网格,问使用 这样的占三个格子图形填充满整个网格的方案数 如果 \(n\) 是奇数,那么显然无解,否则考虑每个 \(3\times2\) 的方格正好能塞下两个这玩意而且必须这样塞进去,方案数为 \(2\),因此答案为 \(2^{n/2}\) B Plus from Picture 给定一个 \(h\times w\) 的矩阵,每个元素为 "." 或者…
A. Filling Diamonds 题意:给你n个菱形方块,问能构成图示形状的有多少种 题解:自己画几个不难发现答案是n 代码: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <stack> 7 #include <queue> 8 #…
Codeforces Round #589 (Div. 2)-E. Another Filling the Grid-容斥定理 [Problem Description] 在\(n\times n\)的格子中填入\([1,k]\)之间的数字,并且保证每一行至少有一个\(1\),每一列至少有一个\(1\),问有多少种满足条件的填充方案. [Solution] 令\(R[i]\)表示为第\(i\)行至少有一个\(1\)的方案数,\(C[i]\)表示第\(i\)列至少有一个\(1\)的方案数.则题目要…