UVA 1589:Xiangqi (模拟 Grade D)】的更多相关文章

题目: 象棋,黑棋只有将,红棋有帅车马炮.问是否死将. 思路: 对方将四个方向走一步,看看会不会被吃. 代码: 很难看……WA了很多发,还越界等等. #include <cstdio> #include <cstring> #include <cstdlib> ][]; ][] = {{,},{,},{-,},{,-}}; bool inBlackPalace(int x, int y) { <= y && y <= && &…
●赘述题意 给出一个中国象棋残局,告诉各个棋子的位置,黑方只有1枚“将”,红方有至少2枚,至多7枚棋子,包含1枚“帅G”,和若干枚“车R”,“马H”,“炮C”.当前为黑方的回合,问黑方的“将”能否在移动一步后不被“将军”. ●题解 本题就是一个模拟:枚举“将”向四个方向走,是否满足题意. 但比较考察逻辑和代码能力. 但有一个坑点: “将”在移动时,不能移动到与“帅”照面. 但,恶心的数据会有输入的局面就出现将帅照面的情况,按理说,应是黑方赢了(因为轮到黑方的回合),也就是说在程序中加一个特判.但…
题意:背景就是象棋, 题解:坑点1(wa的第一天):将军可以吃掉相邻的棋子,(然行列也写反了orz) 坑点2(wa的第二天):将军到马要反过来写,边界有误,并且第一次碰到的车才算(写到后来都忘了) #define _CRT_SECURE_NO_WARNINGS #include<cmath> #include<iostream> #include<stdio.h> #include<algorithm> #include<cstring> usi…
Xiangqi is one of the most popular two-player board games in China. The game represents a battle between two armies with the goal of capturing the enemy's "general" piece. In this problem, you are  given a situation of later stage in the game. B…
题目 题目     分析 无力了,noip考完心力憔悴,想随便切道题却码了250line,而且还是错的,知道自己哪里错了,但特殊情况判起来太烦了,唯一选择是重构,我却没有这勇气. 有空再写吧,最近真的快疯了.     代码 对拍 #include <bits/stdc++.h> int main() { for(int i=1;i<=100;i++){ system("rand.exe > in.txt"); system("1589.exe <…
题意: 对于一个n元组(a0,a1,...),一次变换后变成(|a0-a1|,|a1-a2|,...) 问1000次变换以内是否存在循环. 思路: 模拟,map判重 代码: #include <cstdio> #include <cstring> #include <map> #include <cmath> #include <algorithm> using namespace std; struct Node{ ]; int n; void…
题意: 格式化代码.每个单词对齐,至少隔开一个空格. 思路: 模拟.求出每个单词最大长度,然后按行输出. 代码: #include <cstdio> #include <cstdlib> #include <cstring> ][][]; ]; ]; typedef char * pchar; int readStr(pchar &str, char *out) { ; int ret = sscanf(str, "%s%n", out, &…
题目链接 题意:一张纸,每次从右往左对折.折好以后打开,让每个折痕都自然的呈90度.输出形状. 思路:模拟折……每次折想象成把一张纸分成了正面在下的一张和反面在上的一张.维护左边和方向,然后输出.细节有点多. 代码: #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; #define N (1<<13)+…
Xiangqi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4121 Description Xiangqi is one of the most popular two-player board games in China. The game represents a battle between two armies with the goal of captu…
UVA 246 - 10-20-30 题目链接 题意:给52张的扑克堆,先从左往右发7张牌,之后连续不断从左往右发7张牌,假设有牌堆形成了下面3种情况(按顺序推断): 1.头两张+尾一张和为10或20或30 2.头一张+尾两张和为10或20或30 3.尾三张和为10或20或30 就把这三张牌拿走,放到总牌堆底(这步要不断运行直到不再满足条件或牌堆没了) 假设有一个牌堆由于这个操作被取完了,那么以后将不在这个位置发牌. 假设最后7个牌堆都能够消掉,那么赢,总牌堆用完,那么输,否则平(即不断循环)…