
UVA
Apache-Wang
学习不是灌输,而是点燃
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
UVa 489 Hangman Judge
本题还是利用字符串匹配,根据题目意思如果匹配的字符错误次数超过7次,就会输。所以本题可以利用变量计算统计共出现错误的次数即可。#include <stdio.h> #include <string.h> #define maxn 100 int left, chance; char s[maxn], s2[maxn]; int win, lose;//flag数组void guess(char ch原创 2016-05-24 07:51:39 · 468 阅读 · 0 评论 -
UVA 227
将空格字符定位,再将其做相应的移动 #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #include <cmath> using namespace std; char转载 2016-06-05 09:22:42 · 438 阅读 · 0 评论 -
UVa 1586 Molar Mass
本题主要是考察字符串匹配问题,思路就是先匹配字符,找到相应的原子量,再与后面的数字进行乘法运算,在求和。需要注意的有两个方面:第一、数字可能不止一位所以考虑匹配时要考虑清楚,第二、在化学分子式中有些较为复杂的基,如本题中-OH,以下是别人的代码。#include <stdio.h> #include <string.h> #include <ctype.h> #define MAXN 100char转载 2016-05-21 09:11:42 · 495 阅读 · 0 评论 -
uva 101 The Blocks Problem
#include <cstdio> #include <string> #include <vector> #include <iostream> using namespace std; const int maxn = 30; int n; vector<int> pile[maxn]; //每个pile[i]是一个vector //找木块a所在的pile 和height,以引用的形式返回调用者翻译 2016-05-26 18:13:50 · 305 阅读 · 0 评论 -
UVA 10474 Where is the Marble
这是一道较为简单的匹配问题,先用sort函数对输入的数组进行排序,在通过查找元素,找到目标元素所在位置并输出#include <cstdio> #include <algorithm> using namespace std;const int maxn = 10000;int main(){ int n, q, x, a[maxn], kase = 0; while(scanf("原创 2016-05-25 18:31:12 · 363 阅读 · 0 评论 -
UVa 201 Squares
边用Hij 和 Vij 表示,分别代表(i,j)-(i,j+1)和(i,j)-(i+1,j)原题中的样例:SampleInput 4 16 H 1 1 H 1 3 H 2 1 H 2 2 H 2 3 H 3 2 H 4 2 H 4 3 V 1 1 V 2 1 V 2 2 V 2 3 V 3 2 V 4 1 V 4 2 V 4 3 2 3 H 1 1 H 2转载 2016-05-24 17:56:26 · 6385 阅读 · 0 评论 -
UVa 1589 Xiangqi
本题看起来是比较复杂的一类问题,要模拟实际生活中象棋的走法,但其实并不是很复杂,根据题目意思需要分成四类情况进行讨论:1、对将 2、车 3、炮 4、马。其中复杂度也是按照这个顺序排的,最复杂的是马的情况,根据以上的推断写出如下程序:#include <bits/stdc++.h>//可以包含所有c++的头文件,但使用要慎重,不是每个oj都能通过的 using namespace std;转载 2016-05-24 17:22:52 · 406 阅读 · 0 评论 -
UVa 512 Spreadsheet Tracking
#include <stdio.h> #include <string.h> #define maxd 100 #define BIG 10000 int r, c, n, d[maxd][maxd], d2[maxd][maxd], ans[maxd][maxd], cols[maxd];void copy(char type, int p, int q) { if(type == 'R'翻译 2016-05-24 15:56:15 · 381 阅读 · 0 评论 -
UVa 213 Message Decoding
#include <stdio.h> #include <string.h>int readchar()//如没有遇到'\r'或'\n'时,返回ch { for(;;) { int ch = getchar(); if(ch != '\n' && ch != '\r') return ch; } }int readint翻译 2016-05-24 15:14:03 · 384 阅读 · 0 评论 -
UVa 133 The Dole Queue
本题有点类似约瑟夫环问题,但从复杂性来讲,是在约瑟夫环的基础上增加了一层,可以说是前后两次的约瑟夫问题。主要的思路就是用一个标记数组表示哪些元素已经被选出来了,再将他们输出。本题最巧妙的一部分就是运用+/-1将两个操作统一起来了。#include <stdio.h> #define maxn 25 int n, k, m, a[maxn];int go(int p, int d, int t) {原创 2016-05-24 12:12:39 · 485 阅读 · 0 评论 -
UVa 455 Periodic Strings
本题是在ACM比赛中经常出现的一类题目,找出最小子串的问题,可用多种方法求解,在这里列举几种一、直接暴力枚举法#include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> using namespace std; char str[104]; int main() { int n原创 2016-05-23 18:51:26 · 358 阅读 · 0 评论