
【OJ】
文章平均质量分 78
fanfan4569
登上山顶,欣喜掩盖疼痛。
展开
-
【PAT】1023. Have Fun with Numbers (20)
题目链接:https://www.patest.cn/contests/pat-a-practise/1023 Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we wil原创 2018-01-29 22:34:47 · 252 阅读 · 0 评论 -
UVa232 Crossword Answers
坑点:1。输出按顺序来,Across时正常,Down时要把所访问过得num置02。非第一例要空一行下面上代码#include<cstdio>#include<cstring>#define MAXN 12char pic[MAXN][MAXN];int num[MAXN][MAXN];int r, c;int cnt;bool isNoBlank(int x, int y){原创 2016-06-26 17:20:09 · 388 阅读 · 0 评论 -
UVa1368 DNA Consensus String
题意:1、查找每行的元素出现的对多次,即为频率最高,且相似最大2、每个位置没出现的次数。下面上代码:#include<cstdio>#include<cstring>int N, M;char DNA[55][1010];int List[5];void solve(){ int ans = 0; for(int i = 0 ; i < N; ++i){ mem原创 2016-06-27 15:47:32 · 319 阅读 · 0 评论 -
UVa10340 All in All
水题坑点:边读边判断。#include<cstdio>#include<cstring>#define MAXN 1010char s[MAXN], t[MAXN];void solve(){ char c; int i = 0, len = strlen(t); while((c = getchar()) != '\n'){ if(c == t[i])原创 2016-06-29 16:26:57 · 461 阅读 · 0 评论 -
UVa Box 1587
水题注意点:· 长宽不等 · 三组不同 · 三个不同的面两两包含共同边#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int w[10], h[10];int a[10];void solve(){ memset(a, 0, sizeof(a)); int cnt = 0;原创 2016-06-30 16:42:02 · 455 阅读 · 0 评论 -
UVA 11809
不会看题 不懂题意,蒟蒻的我参考http://blog.youkuaiyun.com/xyqcl/article/details/40011009我的理解:题意: 输入科学计数法的十进制 跟 二进制数 作比较,(注意题意是正数,按正规数格式来 所以小数是以0.1开始 所以尾数尾数起始是1)思想: 打表,C D 和 表里作比较,如果思路: A * 2^B = C * 10^D 取对数 log10(A)原创 2016-10-03 13:53:24 · 524 阅读 · 0 评论 -
【蓝桥杯】算法提高 夺宝奇兵
/** 题意: 题意不明, 实则是,上一条路能选他对应下一条和他下一条的右边那一条。 思路: 01背包相似。*/#include<cstdio>#include<algorithm>using namespace std;#define MAXN 101int N;int mountain[MAXN][MAXN];int dp[MAXN + 1]原创 2017-03-05 21:00:27 · 1751 阅读 · 0 评论 -
蓝桥杯历届试题---蚂蚁感冒
水题 #include#includeusing namespace std;#define MAX_N 105int N;int a[MAX_N];int cnt = 1;void solve(){ bool flag = false; int cnt2 = 0; if(a[0] > 0){ //朝右 for原创 2016-05-15 20:10:09 · 677 阅读 · 0 评论 -
【蓝桥杯题】 之 算法训练-字串统计
问题描述 给定一个长度为n的字符串S,还有一个数字L,统计长度大于等于L的出现次数最多的子串(不同的出现可以相交),如果有多个,输出最长的,如果仍然有多个,输出第一次出现最早的。 输入格式 第一行一个数字L。 第二行是字符串S。 L大于0,且不超过S的长度。 输出格式 一行,题目要求的字符串。 输入样例1: 4 bbaabbaaaaa 输出样例1:原创 2017-01-17 17:36:13 · 1814 阅读 · 2 评论 -
【蓝桥杯题】之 算法训练-寂寞的数
问题描述 道德经曰:一生二,二生三,三生万物。 对于任意正整数n,我们定义d(n)的值为为n加上组成n的各个数字的和。例如,d(23)=23+2+3=28, d(1481)=1481+1+4+8+1=1495。 因此,给定了任意一个n作为起点,你可以构造如下一个递增序列:n,d(n),d(d(n)),d(d(d(n)))….例如,从33开始的递增序列为: 33, 39, 51原创 2017-01-17 18:21:25 · 2003 阅读 · 0 评论 -
算法提高 12-2扑克排序
问题描述 扑克牌排序:构造扑克牌数组,对扑克牌进行排序。排序原则如下:数字从小到大是2-10、J、Q、K和A,花色从小到大是方块(diamond)、梅花(club)、红桃(heart)、黑桃(spade)。两张牌比较时先看数字,数字相同时看花色。要求对输入的扑克牌进行从小到大排序。 输入五张牌(表示黑桃2、红桃3、黑桃3、方块A和梅花J): 2 s 3 h 3 s A d J c原创 2017-03-17 21:15:43 · 881 阅读 · 0 评论 -
UVa1225
转自:http://blog.youkuaiyun.com/mobius_strip/article/details/44346607orz ,蒟蒻的我。一开始题意没看清,万脸懵逼。题意:1~10000 中连续数字排列,统计0~9出现的次数。方法:打表, % 。#include#includeusing namespace std;int f[10转载 2016-06-20 14:33:24 · 472 阅读 · 0 评论 -
UVa227 Puzzle
这题的坑点就是换行和交换时候都要检查一遍下面上代码#include<cstdio>#include<cstring>#include<iostream>using namespace std;char pic[10][10];char order[100];bool flag = false;bool isRange(int a){ if(a < 0 || a >=5){原创 2016-06-25 20:04:27 · 506 阅读 · 0 评论 -
【PAT】1029. Median (25)
题目链接:https://www.patest.cn/contests/pat-a-practise/1029 Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12,原创 2018-02-05 12:59:53 · 291 阅读 · 0 评论 -
【PAT】1021. Deepest Root (25)
题目链接:https://www.patest.cn/contests/pat-a-practise/1021 A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supp原创 2018-01-29 00:33:32 · 285 阅读 · 0 评论 -
【PAT】1028. List Sorting (25)
题目链接:https://www.patest.cn/contests/pat-a-practise/1028 Excel can sort records according to any column. Now you are supposed to imitate this function. Input Each input file contain原创 2018-02-02 17:36:25 · 202 阅读 · 0 评论 -
【PAT】1019. General Palindromic Number (20)
题目链接: https://www.patest.cn/contests/pat-a-practise/1019 A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a p原创 2018-01-26 15:25:19 · 185 阅读 · 0 评论 -
【PAT】1027. Colors in Mars (20)
题目链接:https://www.patest.cn/contests/pat-a-practise/1027 People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit numbe原创 2018-02-01 23:28:21 · 192 阅读 · 0 评论 -
【PAT】1015. Reversible Primes (20)
A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a pr原创 2018-01-25 16:03:18 · 236 阅读 · 0 评论 -
【PAT】1025. PAT Ranking (25)
题目链接:https://www.patest.cn/contests/pat-a-practise/1025 Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is sup原创 2018-02-01 10:42:43 · 255 阅读 · 0 评论 -
【PAT】1024. Palindromic Number (25)
题目链接: A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are pal原创 2018-01-30 20:11:16 · 220 阅读 · 0 评论 -
树状数组------冒泡排序的交换次数
题意:给定一个1~n的排列a0, a1, a2, ..., an-1, 求对这个数列进行冒泡排序所需要的交换次序(冒泡排序是每次找到满足ai > ai+1 的i, 并交换ai 和 ai+1,直到这样的i不存在为止的算法)。input: n = 4, a = {3, 1, 4, 2}output:3所求的交换次序等价于满足i aj 的(i, j)数对的个数(这种数对原创 2016-05-14 19:35:31 · 1587 阅读 · 0 评论 -
最大连续子序列和(小结)
解决最大子序列有如下几种。1. 暴力求解 o(n^3) 2. 暴力求解(优化点) o(n^2)以上两种也是最容易想到的,这就不细说了。3. 分而治之 o(nlogn)int Max3( int A, int B, int C ){ /* 返回3个整数中的最大值 */ return A > B ? A > C ? A : C : B原创 2016-06-17 20:13:34 · 467 阅读 · 0 评论 -
算法提高 勾股数
算法提高 勾股数 时间限制:1.0s 内存限制:256.0MB 提交此题 问题描述 勾股数是一组三个自然数,a < b < c,以这三个数为三角形的三条边能够形成一个直角三角形 输出所有a + b + c <= 1000的勾股数 a小的先输出;a相同的,b小的先输出。 输出格式 每行为一组勾股数,用空格隔开 样例输出 例如,结果的前三行应当是 3 4 5原创 2017-03-24 20:48:29 · 1391 阅读 · 0 评论 -
算法提高 快乐司机
/** 2017.3.25 Donald*//** 思路:不用dp, 直接按其价值比,从高到底堆积。*/#include<bits/stdc++.h>using namespace std;#define MAXN 10001int N; //物品的数目int W; //荷载重量//pair.second .first : weight, .second原创 2017-03-26 16:29:35 · 412 阅读 · 0 评论 -
1012. The Best Rank (25)
To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algebra), and E - Engl原创 2017-03-10 23:22:50 · 269 阅读 · 0 评论 -
1009. Product of Polynomials (25)
This time, you are supposed to find A*B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the information原创 2017-03-06 15:26:35 · 272 阅读 · 0 评论 -
1008. Elevator (20)
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seco原创 2017-03-05 20:49:21 · 249 阅读 · 0 评论 -
1001. A+B Format (20)
/** 2017.2.26 Donald*///1001. A+B Format (20)/** 思路: 若大于4位,每过3位(7 和 4),则用逗号隔开;否则不用*/#include<cstdio>#include<cmath>#include<stack>using namespace std;stack<char> S;int main(void){原创 2017-02-26 19:20:37 · 240 阅读 · 0 评论 -
1010. Radix (25)
参考http://www.cnblogs.com/549294286/p/3571604.html Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is “yes”, if 6 is a decimal number and 110原创 2017-03-08 16:24:58 · 306 阅读 · 0 评论 -
1011. World Cup Betting (20)
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Sim原创 2017-03-08 16:15:22 · 303 阅读 · 0 评论 -
1006. Sign In and Sign Out (25)
At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in’s and out’s, you原创 2017-03-03 10:39:42 · 370 阅读 · 0 评论 -
1005. Spell It Right (20)
Spell It Right (20)Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file contains one原创 2017-03-02 13:15:10 · 342 阅读 · 0 评论 -
1004. Counting Leaves (30)
参考http://www.cnblogs.com/wwblog/p/3704428.htmlA family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.InputEach input file contains one原创 2017-03-01 14:54:25 · 302 阅读 · 0 评论 -
1003. Emergency (25)
As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the le原创 2017-02-28 15:07:55 · 256 阅读 · 0 评论 -
5-12 排序 (25分)
针对不同的排序题目:给定NN个(长整型范围内的)整数,要求输出从小到大排序后的结果。本题旨在测试各种不同的排序算法在各种数据情况下的表现。各组测试数据特点如下:数据1:只有1个元素;数据2:11个不相同的整数,测试基本正确性;数据3:103个随机整数;数据4:104个随机整数;数据5:105个随机整数;数据6:105个顺序整数;数据7:105个逆序整数;数据8:105个基本有序的整数;原创 2016-12-14 21:14:38 · 678 阅读 · 0 评论 -
06-图3 六度空间 (30分)
题目链接:https://pta.patest.cn/pta/test/1342/exam/4/question/22502思路:注意层数判断 即需要last tail 进行判断codeblock 快捷键ctrl+shift+c可以快速注释掉多行。ctrl+shift+x可以取消注释#include<cstdio>#include<cstring>#include<queue>using na原创 2016-11-13 17:02:48 · 1242 阅读 · 0 评论 -
UVa455
转自:http://blog.youkuaiyun.com/mobius_strip/article/details/40584263//暴力,数组运用,适合小数据#include#includeusing namespace std;char str[85];int main(){ int T; scanf("%d", &T); while(T--){转载 2016-06-21 19:51:11 · 462 阅读 · 0 评论 -
01-复杂度2 Maximum Subsequence Sum
题目:https://pta.patest.cn/pta/test/1342/exam/4/question/18204题意: 输入K个数,找到最大子串,输出 最大和、最大子串的第一个数和最后一个数。 如果最大和为负,则输出 最大和为0、数列第一个数 和 数列最后一个数重点: MaxSum = Num[0]#include<cstdio>using namespace std;int Num[原创 2016-10-04 11:19:57 · 330 阅读 · 0 评论 -
02-线性结构1 两个有序链表序列的合并 (15分)
题目:https://pta.patest.cn/pta/test/1342/exam/3/question/19208注意 提交时候只需要把Merge的函数提交即可#include <stdio.h>#include <stdlib.h>typedef int ElementType;typedef struct Node *PtrToNode;struct Node { Elem原创 2016-10-05 16:22:50 · 1328 阅读 · 2 评论