UVa 769 Magic of David Copperfield(构造)
2015-05-06 09:03
459 查看
题意:
一个魔术师表演魔术,给出n,表示说有n张牌,有序的排成n*n的矩阵,现在请上若干个观众来,从上一个人移动到的位置开始移动k步(2∗n≤k≤100002*n≤k≤10000),任意方向,并且不能和前面人的k一样大小。然后魔术师每次可以抽点若干张观众走不到的牌,使得最后桌子上只有一张牌,问是否有这种可能。
解析:
棋盘问题,在国际象棋的棋盘上,每次走奇数步肯定落在与起始位置颜色不同的位置,这道题就是这样,每次走奇数步,然后按照对角线拿掉牌。AC代码:
[code]#include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <cstdlib> using namespace std; typedef long long ll; int n; int main() { int T; scanf("%d", &T); while(T--) { scanf("%d", &n); int cnt = 1; for(int i = 1; i <= n; i++) { printf("%d", 2*(n+cnt++)-1); for(int j = 0; j < i; j++) { printf(" %d", i+(n-1)*j); }puts(""); } for(int i = 2; i < n; i++) { printf("%d", 2*(n+cnt++)+3); for(int j = 0; j <= n-i; j++) { printf(" %d", n*i+j*(n-1)); }puts(""); } if(T) puts(""); } return 0; }
相关文章推荐
- uva 769 - Magic of David Copperfield(构造)
- UVA 769 - Magic of David Copperfield(构造问题)
- UVA - 769 Magic of David Copperfield 构造
- UVa 769 - Magic of David Copperfield 解题报告(思维)
- UVA - 769 Magic of David Copperfield
- 构造 - SGU 109 Magic of David Copperfield II
- sgu109 Magic of David Copperfield II 构造
- SGU 109 Magic of David Copperfield II(构造)
- 构造 - SGU 109 Magic of David Copperfield II
- SGU 109 Magic of David Copperfield II(构造)
- sgu109:Magic of David Copperfield II
- SGU109 Magic of David Copperfield II
- 构造/sgu109 Magic of David Copperfield II
- SGU 109 Magic of David Copperfield II 奇偶性
- SGU 109 Magic of David Copperfield II 翻译 题解
- Magic of David Copperfield II(奇偶性)
- SGU 109 Magic of David Copperfield II
- sgu 109 Magic of David Copperfield II
- SGU 109 Magic of David Copperfield II
- SGU 109 Magic of David Copperfield II