
UVA
麻辣猪仔
这个作者很懒,什么都没留下…
展开
-
DNA Consensus String UVA - 1368
#include <iostream>#include <string>using namespace std;int m, n; // 行数,列数string strs[50]; // 存储每一行int num = 0;string result; // 存储结果void Counts();int main() { int T; // ...原创 2018-10-31 08:25:50 · 95 阅读 · 0 评论 -
Extraordinarily Tired Students UVA - 12108
#include <iostream>#include <string>#include <set>#define _for(i, a, b) for (int i = (a); i < (b); ++i)using namespace std;struct Stu { int A, B, C;} stus[15];set<...原创 2018-11-09 17:01:11 · 120 阅读 · 0 评论 -
Ancient Cipher UVA - 1339
#include <iostream>#include <string>#include <cstring>#include <algorithm>using namespace std;int main() { string s1, s2; int cnt1[26], cnt2[26], flag = 1; while ((c...原创 2018-11-02 11:16:04 · 112 阅读 · 0 评论 -
Hangman Judge UVA - 489
#include <iostream>#include <string>using namespace std;int win, lose;int length, chance, rnd;string s1, s2;void guess(char);int main() { while ((cin >> rnd >> s1 ...原创 2018-11-02 11:38:04 · 169 阅读 · 1 评论 -
Spreadsheet Tracking UVA - 512
根据紫书做的,非常佩服作者的思路,我只改了一点点内容第一段代码的思路是直接模拟操作,算出最后的电子表格,然后在最后的查询操作根据电子表格找出对应的单元格#include <iostream>#include <cstring>#include <string>using namespace std;#define maxd 100#def...原创 2018-11-04 11:51:08 · 129 阅读 · 0 评论 -
The Dole Queue UVA - 133
觉得主要还是开始的时候,两个官员的位置吧,要往前挪一位#include <iostream>#include <cstring>using namespace std;int n, k, m, a[25];int go(int official, int d, int t); // 官员official,d表示顺逆时针(-1表顺时针,1表逆时针),t表...原创 2018-11-02 21:54:59 · 102 阅读 · 0 评论 -
Cube painting UVA - 253
这道题相对于其他人来说用的篇幅比较长吧,方法也比较简单暴力,就是将绕x,y,z轴方向旋转的三个函数都写出来,然后还有一个判断的函数,然后就进行4*4+4*4=32次的旋转然后进行判断,里面应该还是有重复的情况,不过并没有去深究。#include <iostream>#include <string>using namespace std;string col...原创 2018-11-07 17:23:17 · 105 阅读 · 0 评论 -
Squares UVA - 201
还是写得有点啰嗦吧,一开始自己定义的结构体里面有四个变量,结果后面自己在使用的时候发现根本就不需要用到四个,两个就够了...这道题觉得思路还好吧,主要是在题目的说明上面,那里写着的Hij 和 Vij意义是不一样的,应该是Hij 和 Vji,还有就是麻烦的输出格式,这段代码还是可以再做修改的,变得更加简洁。#include <iostream>#include <cst...原创 2018-11-07 23:46:22 · 156 阅读 · 0 评论 -
A Typical Homework (a.k.a Shi Xiong Bang Bang Mang) UVA - 12412
这道题总体还好就是过程挺长的要考虑的东西就多起来了#include <iostream>#include <string>#include <cstring>using namespace std;#define MAX 105#define EPS 1e-5struct student{ string sid; int cid; ...原创 2018-11-05 22:29:46 · 132 阅读 · 0 评论 -
Flooded! UVA - 815
#include <stdio.h>#include <iostream>#include <algorithm>using namespace std;int a[500];int main(){ int m, n, kase = 0; double V; while (cin >> m >> ...原创 2018-11-30 22:59:43 · 115 阅读 · 0 评论 -
IP Networks UVA - 1590
#include <iostream>#include <cstdio>#include <cstring>#define _for(i, a, b) for (int i = (a); i < (b); i++)using namespace std;const int W = 8, IPW = 4*W;void printIp(co...原创 2018-11-30 23:55:33 · 175 阅读 · 0 评论 -
Floating-Point Numbers UVA - 11809
根据题意,可以推断出最大值又因为数字的数值过大,所以可以同时求以10为底的对数,即:根据题目要求所以可以根据式子先求出对应的lgv的值,然后根据式子可以推出对M由0到9进行遍历,并求出对应的E值(取整数),计算出对应的lgv值与前面的lgv进行比较,若差值较小(取1e-4)则输出对应的M和E,代码如下#include <iostr...原创 2018-11-02 00:33:52 · 134 阅读 · 0 评论 -
Kickdown UVA - 1588
这道题固定一块板,然后另一块板分别左移和右移,找出对应的最小值就好了#include <iostream>#include <string>#include <algorithm>using namespace std;int main(){ string s1, s2, s3; int length1, length2; while(c...原创 2018-11-01 21:24:51 · 115 阅读 · 0 评论 -
Puzzle UVA - 227
这道题...输出格式令人好无语,用c写不下去了,一直AW,心态爆炸改用c++重写,改了贼多次,终于搞定#include <iostream>#include <string>using namespace std;string strs[5];int x, y; // 记录空格的坐标int first = 1; // 判断是否为第一个输出int k...原创 2018-10-29 22:22:01 · 88 阅读 · 0 评论 -
Crossword Answers UVA - 232
这道题觉得主要还是格式问题吧,Down的输出值还需要按顺序排列,一开始没去想后面才发现,在原基础上改了半天,还好最后AC了#include <iostream>#include <string.h>#include <string>using namespace std;int r, c; // r行和c列int first = 1; /...原创 2018-10-30 00:37:41 · 157 阅读 · 0 评论 -
Repeating Decimals UVA - 202
觉得这道题主要还是理解停止条件是什么,用两个数组分别存储除数和余数,当出现一组除数和余数存在于数组当中时就出现了循环#include <iostream>#include <vector>using namespace std;int main() { int a, b, flag = 0, length = 0, start = 0; // lengt...原创 2018-10-31 21:24:15 · 86 阅读 · 0 评论 -
All in All UVA - 10340
#include <iostream>#include <string>#include <stack>using namespace std;int main() { string s, t; stack<char> st1, st2; while (cin >> s >> t) { for (int...原创 2018-10-31 22:02:50 · 187 阅读 · 0 评论 -
Score UVA - 1585
#include <stdio.h>#include <string.h>int score(const char * str) { int a = 0, b = 1; for (int i = 0; i < strlen(str); i++) { if (str[i] == 'O') a += b++; else b = 1; }...原创 2018-10-27 14:29:40 · 128 阅读 · 0 评论 -
Molar mass UVA - 1586
#include <stdio.h>#include <ctype.h>const double C = 12.01;const double H = 1.008;const double O = 16.00;const double N = 14.01;double molar();double panduan(char);int main() {...原创 2018-10-27 14:32:25 · 112 阅读 · 0 评论 -
Digit Counting UVA - 1225
#include <stdio.h>#include <string.h>int counts[15] = {0};void DigitCounting(int n);int main() { int T, n, first = 1; scanf("%d", &T); while (T--) { scanf("%d", &n);...原创 2018-10-27 14:33:48 · 108 阅读 · 0 评论 -
Periodic Strings UVA - 455
#include <stdio.h>#include <string.h>int PeriodicStrings(const char *);bool equal(const char, const char); // 判断两个字符是否相等int main() { int T; char str[100]; scanf("%d", &T); ...原创 2018-10-27 14:35:09 · 110 阅读 · 0 评论 -
Message Decoding UVA - 213
这道题还是对紫书上的做了修改吧,修改后就AC了#include <iostream>#include <cstring>#include <string>using namespace std;int readchar(); // 读取一个非换行字符int readnchar(int c);int readcodes();int co...原创 2018-11-03 10:46:10 · 136 阅读 · 0 评论 -
Box UVA - 1587
#include <iostream>#include <algorithm>using namespace std; struct pairs{ int w, h;}array[6]; bool cmp(pairs a,pairs b){ if (a.w != b.w) return a.w < b.w; else return a....原创 2018-11-01 20:30:47 · 179 阅读 · 0 评论 -
The SetStack Computer UVA - 12096
虽然这段是AC不了的,但主要还是学习里面STL的使用方法#include <bits/stdc++.h>#define ALL(x) x.begin(), x.end()#define INS(x) inserter(x, x.begin())using namespace std;typedef set<int> Set;map<Set, in...原创 2019-01-27 16:21:59 · 129 阅读 · 0 评论