A.
题目链接:点击打开链接
解题思路:
大意就是说奇数位给小写字母,偶数位给大写字母,然后小写对应钥匙,大写对应门,问最少消耗几把钥匙能打开所有门。
简单模拟即可,初始化一个英文字母数组,如果遇到小写字母,我们把相应的计数器++,遇到大写,如果它对应的数组值不为0,那么我们将其--,
否则购买一把钥匙。
完整代码:
#include
#include
#incl...
分类:
编程语言 时间:
2015-03-30 11:28:29
阅读次数:
143
解题思路:
裸的匈牙利算法,看最大匹配是否等于P;
#include
#include
#include
#include
#include
#include
using namespace std;
const int MAXN = 500;
int p, n;
int G[MAXN][MAXN];
int match[MAXN];
int vis[MAXN];
int path...
分类:
其他好文 时间:
2015-03-30 11:28:29
阅读次数:
118
题目:
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
思路:根据前序和中序的特点 递归调用创建二叉树
#include
#include
u...
分类:
其他好文 时间:
2015-03-30 11:26:36
阅读次数:
122
题目:n个人围成一圈编号1~n,玩传球游戏,从编号k的人开始,每次传给下一个人,第p次传球到谁。
分析:简单题。直接取余数即可。
说明:注意结果是0的情况。
#include
#include
using namespace std;
int main()
{
int n,k,p,t,ans;
while (cin >> t)
for (int i = 1 ; i <= t ;...
分类:
其他好文 时间:
2015-03-30 11:25:10
阅读次数:
97
Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
#include
#include
#include
using namespace std;
struct TreeNode {
int val;...
分类:
其他好文 时间:
2015-03-30 11:24:41
阅读次数:
121
解题思路:
枚举棋盘上所有格子,如果讲该点删除后,最大匹配数会减少,则该点为关键点。
#include
#include
#include
#include
#include
#include
using namespace std;
const int MAXN = 100 + 10;
int G[MAXN][MAXN];
int vis[MAXN];
int match[MAX...
分类:
其他好文 时间:
2015-03-30 11:24:10
阅读次数:
106
这题之前CC做过类似的,思路如官方题解。
代码:
#include
#include
#include
using namespace std;
const int N = 100005;
typedef long long ll;
int n, m;
ll q;
struct Hash {
int v, id;
void read(int id) {
...
分类:
编程语言 时间:
2015-03-30 11:21:20
阅读次数:
116
Brief description :
猜数问题:有一个被猜数X,是1到N的范围内的整数,你每次可以给出一个整数Y。你会在你问下一个问题之后得到你这个问题的回答,即X与Y的大小关系。并且如果你得到了K次X
Analyse:
f[i][j],表示i次猜数,j次X
友链:猜数问题研究论文
CODE:
#include
#include
#include
#include
#includ...
分类:
其他好文 时间:
2015-03-30 11:20:59
阅读次数:
106
在进行native开发的时候,难免会遇到C文件包含C++头文件而调用C++函数,若没做什么处理,直接include进行编译的话,会遇到以下错误:
error: unknown type name 'class'
error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
那么怎么解决呢?
首先,找下报...
分类:
编程语言 时间:
2015-03-30 11:18:06
阅读次数:
225
简单题,先从右边消起,注意结束时a[1]==0才能是yes#include #include #include #include using namespace std;const int N=1000050;int a[N],n;int main(){ int T; scanf("%d",&T);...
分类:
其他好文 时间:
2015-03-30 10:55:05
阅读次数:
98