书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,10 ms) //UVa508 - Morse Mismatches #include<iostream> #include<string> #include<map> using namespace std; map<char, string> morse; map<string, string> word; string wo, tra…
题意:在前100000个Fibonacci(以下简称F)数字里,能否在这100000个F里找出以某些数字作为开头的F.要求找出下标最小的.没找到输出-1. 代码:(Accepted,0.250s) //UVa12333 - Revenge of Fibonacci //Accepted 0.250s //#define _XIENAOBAN_ #include<iostream> #include<cstring> #define MAXS 0xffffff #define CIN…
题意:模拟客服MM,一共有N种话题,每个客服MM支持处理其中的i个(i < N),处理的话题还有优先级.为了简化流程方便出题,设每个话题都是每隔m分钟来咨询一次.现知道每个话题前来咨询的时间.间隔.处理此话题所需的时长与一共有多少次咨询.问多少时间后全部话题处理完成. 代码:(Accepted,0.010s) //UVa822 - Queue and A //Accepted 0.010s //#define _XIENAOBAN_ #include<algorithm> #includ…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa1590 - IP Networks #include<iostream> unsigned i, m, num, ip[4], ipmax[4], ipmin[4], mask[4]; int cmp(unsigned *a, unsigned *b) {//compare for (int i = 0;i < 4;++i) { if (a[i] <…
题意:模拟Petri网的执行.虽然没听说过Petri网,但是题目描述的很清晰. 代码:(Accepted,0.210s) //UVa804 - Petri Net Simulation //Accepted 0.210s //#define _XIENAOBAN_ #include<iostream> #include<map> using namespace std; struct { map<int, int> ipt, opt; } Trans[111]; int…
题意:二叉树代表使得平衡天平,修改最少值使之平衡. 代码:(Accepted,0.030s) //UVa12166 - Equilibrium Mobile //Accepted 0.030s //#define _XIENAOBAN_ #include<cstdio> #include<cstring> #include<map> int T; int total; std::map<long long, int> leaf; void build(int…
这三题比较简单,只放代码了. 题目:6-1 UVa673 - Parentheses Balance //UVa673 - Parentheses Balance //Accepted 0.000s //#define _XIENAOBAN_ #include<iostream> using namespace std; int N; char line[130]; bool st[130]; bool cal() { if (*line == '\0') return true; auto…
题意:模拟患者做手术. 其条件为:医院有Nop个手术室.准备手术室要Mop分钟,另有Nre个恢复用的床.准备每张床要Mre分钟,早上Ts点整医院开张,从手术室手术完毕转移到回复床要Mtr分钟.现在医院早上开张了,给你一张患者的表,有Npa个患者等着做手术,每个患者的的信息有:名字.做手术需要的时间.恢复需要的时间.只要有空的手术室位就安排患者进去,优先安排门牌号低的.若多人同时竞争,输入列表靠前的先进.进入恢复室的优先顺序是,也是优先安排床号靠前的床,同时做完手术的人按照手术室的门牌号小的 (很…
题意:对比新老字典的区别:内容多了.少了还是修改了. 代码:(Accepted,0.000s) //UVa12504 - Updating a Dictionary //#define _XieNaoban_ #include<iostream> #include<sstream> #include<string> #include<vector> #include<map> using namespace std; int T; int mai…
题意:不难理解,照搬题意的解法. 代码:(Accepted,0.190s) //UVa1597 - Searching the Web //#define _XIENAOBAN_ #include<iostream> #include<sstream> #include<cstring> #include<string> #include<vector> #include<map> #include<set> using…
题意:问在一个词典里,那些单词是复合词,即哪些单词是由两个单词拼出来的. 渣渣代码:(Accepted, 30ms) //UVa10391 - Compound Words #include<iostream> #include<string> #include<set> using namespace std; set<string> dic; int main() { //freopen("in.txt", "r"…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa815 - Flooded! #include<iostream> #include<algorithm> int M, N, W, S[1000], T = 0; int main() { //freopen("in.txt", "r", stdin); while (scanf("%d%d"…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) #include<iostream> unsigned N, A, B, Sp, Sq, ansA, ansB; unsigned long long Pofs, K, nowK; int main() { //freopen("in.txt", "r", stdin); while (scanf("%u%u%u",…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa12108 - Extraordinarily Tired Students #include<iostream> struct how_cute_my_sleepy_boys_are { int a,//awaken period : a>=1; b,//sleeping period : b<=5; s,//state : 0醒着,1睡觉; t;//…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa509 - RAID! #include<iostream> int d, s, b, t, times = 0; char disk_data[7][6666], type; inline char* disk(int x, int y, int z) {//二维数组当作三维数组使,方便运算 return *(disk_data + x - 1) + (y - 1…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) #include<iostream> char str[15]; void change(int b) {//更换顶上的面 char t; if(b) t = str[0], str[0] = str[1], str[1] = str[5], str[5] = str[3], str[3] = t; else t = str[0], str[0] = str[4], str[…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa1589 #include<iostream> #include<cmath> #define P(x,y) Pi[x].position[y] using namespace std; int N;//2<=N<=7 bool A[4];//around,储存"将"周围是不是已经不能走了 0上 1左 2下 3右 stru…
题意:52张牌排一行,一旦出现任何一张牌与它左边的第一张或第三张"匹配",即花色或点数相同,则须立即将其移动到那张牌上面,将其覆盖.能执行以上移动的只有压在最上面的牌.直到最后没有牌能向左移动. 注意细则:如果同时有多张牌都可以移动,你应该采取的策略是移动最左边可移动的牌.当一张牌既可以移动到左边第一张,又可以移动到左边第三张时,应移动到左边第三张上面. 代码:(Accepted,0.100s) //UVa127 - "Accordian" Patience //A…
题意:黑白图像的路径表示法 代码:(Accepted,0.120s) //UVa806 - Spatial Structures //Accepted 0.120s //#define _XIENAOBAN_ #include<algorithm> #include<iostream> #include<string> #include<vector> #include<cmath> using namespace std; int N, T(0…
比较忙比较累,只贴代码了. 题目:6-4 UVa439 - Knight Moves //UVa439 - Knight Moves //Accepted 0.000s //#define _XIENAOBAN_ #include<iostream> #include<cstring> #include<queue> #define M(po) Map[po.x][po.y] using namespace std; struct poi { int x, y, wei…
题意:模拟买卖,当出售价bid等于或低于出售价ask,则交易. 代码:(Accepted,0.330s) //UVa1598 - Exchange //Accepted 0.330s //#define _XIENAOBAN_ #include<functional> #include<algorithm> #include<iostream> #include<utility> #include<vector> #include<queu…
题意:N张地图,查找某地点在不在某些地图上,若在,使用细节多的地图.使用哪个地图的破要求挺多,细心一点就好. 代码:(Accepted,0.000s) //UVa511 - Do You Know the Way to San Jose? //Accepted 0.000s //#define _XIENAOBAN_ #include<iostream> #include<algorithm> #include<cstring> #include<string&g…
//开学了,好烦啊啊啊啊啊!怎么开个学那么多破事情!!都俩星期了,终于有时间写出来一道题 题意:不难理解,不写了.这几天忙的心累. 代码:(Accepted, 0.010s) //UVa1596 - Bug Hunt #include<iostream> #include<sstream> #include<string> #include<stack> #include<map> using namespace std; struct o_O…
//又开学啦,不知不觉成为大二的老人了...时间过得好快啊,感觉好颓废... 题意:建立一个借书/归还系统.有借.还.把还的书插到书架上这三个指令. 代码:(Accepted, 0ms) //UVa230 - Borrowers #include<iostream> #include<string> #include<map> #include<set> using namespace std; struct BOOK { string au, ti; BO…
题意:一堆文件但只有一个打印机,按优先级与排队顺序进行打印.也就是在一个可以插队的的队列里,问你何时可以打印到.至于这个插队啊,题目说"Of course, those annoying term papers that others are printing may have to wait for quite some time to get printed, but that's life."嗯,这就是生活. 代码:(Accepted, 0ms) //UVa12100 - Pri…
题意:平面上给若干点,问它们是不是关于某垂直于x轴的直线对称. 代码:(Wrong Answer, –ms) //UVa1595 - Symmetry #include<iostream> #include<vector> #include<algorithm> using namespace std; struct point { int x, y; bool operator <(point& that)const { if (y == that.y)…
题意:有若干交换生.若干学校,有人希望从A校到B校,有的想从B到C.C到A等等等等.如果有人想从A到B也刚好有人想从B到A,那么可以交换(不允许一对多.多对一).看作后如果有人找不到人交换,那么整个交换计划失败. 代码:(Accepted, 50ms) //UVa10763 - Foreign Exchange #include<cstdio> #include<cstring> int N, a, b,all[1003][1003]; int main() { //freopen…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa10935 - Throwing cards away I #include<iostream> #include<queue> int N; int main() { //freopen("in.txt", "r", stdin); while (scanf("%d", &N) !=…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,20 ms) //UVa1594 - Ducci Sequence #include<iostream> #include<algorithm> #include<cmath> #include<vector> using namespace std; int T,N; bool is_zero(vector<int> &d) {…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa1593 - Alignment of Code #include<iostream> #include<algorithm> #include<vector> #include<string> #include<sstream> #include<iterator> #include<iomanip…