自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

姚军

富贵非吾愿,帝乡不可期。怀良辰以孤往,或植杖而耘耔。

  • 博客(30)
  • 收藏
  • 关注

原创 反转两个数的乘积

输入两个数,倒着输出两个数的乘积。输入格式:两个数输出格式:一个数输入样例1:5 7输出样例1:53输入样例2:3 1.4输出样例2:2.4输入样例3:8 5输出样例3:4lst = input().split()a,b = eval(lst[0]), eval(lst[1])t = a*bu = str(t)[::-1]i = 0while...

2019-12-29 21:34:12 1016 1

原创 python使用redis连接及TCP服务器和Flask框架

在pycharm的设置中project interpreter中安装redis在windows本地启动redis服务器使用redis连接import redisr = redis.Redis(host='127.0.0.1', port=6379, db=0, decode_responses=True)r.set("number", "201814021024")print(r.ge...

2019-12-29 19:14:44 888

原创 Gin和Iris等Web框架及redis与go的连接使用

参考链接首先安装go然后配置环境变量Windows修改环境变量和网络代理前面两句相当于修改环境变量中的参数,然后才能下载。go env -w GO111MODULE=ongo env -w GOPROXY=https://goproxy.cn,directgo get -u github.com/gin-gonic/gingo get github.com/kataras/iri...

2019-12-28 17:32:56 1360 3

原创 Go语言基础编程题

为了熟练语法,写了点简单的编程题L1-010 比较大小 (10分)题目链接package mainimport "fmt"func main(){ var a,b,c,sum,max,min int fmt.Scanf("%d %d %d",&a,&b,&c) sum = a+b+c max = a min = c if b > max {...

2019-12-27 23:14:57 347

原创 1175. 质数排列

质数数阶乘乘以非质数阶乘计算的过程中容易越界,可以考虑用long long存,返回时强制转换class Solution {public: const int MOD = 1e9+7; int numPrimeArrangements(int n) { int primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43...

2019-12-19 17:16:36 140

原创 4. 寻找两个有序数组的中位数

归并排序的扩展class Solution {public: double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) { int m = nums1.size(); int n = nums2.size(); int...

2019-12-19 16:30:01 140

原创 1266. 访问所有点的最小时间

类似于曼哈顿距离class Solution {public: int minTimeToVisitAllPoints(vector<vector<int>>& points) { //注意题目要求:必须按照数组顺序访问 int sum = 0, f1, s1, f2, s2; int n = points...

2019-12-19 16:04:40 145

原创 1281. 整数的各位积和之差

数字与字符串的转换class Solution {public: int subtractProductAndSum(int n) { string str = to_string(n); int sum = 0, product = 1; for(auto c: str){ sum = sum + c -'0';...

2019-12-19 13:14:13 87

原创 1290. 二进制链表转整数

数位分解class Solution {public: int getDecimalValue(ListNode* head) { int sum = 0; while(head){ sum = sum*2 + head->val; head = head->next; ...

2019-12-19 11:51:43 73

原创 2. 分式化简

最大公约数注意:输出之间的分子分母不用交换class Solution {public: int gcd(int a, int b){ if(b == 0) return a; return gcd(b, a%b); } vector<int> fraction(vector<int>& cont) {...

2019-12-19 11:45:44 178

原创 中美代表

牛客网题目链接可以优化先暴力求解了,由于数据量比较小。#include <cstdio>#include <iostream>#include <string>#include <unordered_map>#include <stack>#include <algorithm>#include <cm...

2019-12-17 11:17:58 189

原创 Emacs计算器

牛客网题目链接后缀表达式计算遇到数值直接放入栈中,遇到操作符将栈顶的两个操作数取出来,然后进行加减乘除操作。注意做除法和减法时,后取出的一个数是被除数和被减数。注意数值中可能有负数。#include <cstdio>#include <iostream>#include <string>#include <unordered_map>#...

2019-12-17 10:56:15 292

原创 数据连接池

牛客网题目链接求总的连接的总数,释放后可以复用。测试样例中没有异常连接。#include <cstdio>#include <iostream>#include <string>using namespace std;int main(){ int n, opt, cur; string str; char C; while (cin &gt...

2019-12-17 10:26:19 115

原创 7-4 Cartesian Tree (30分)

A Cartesian tree is a binary tree constructed from a sequence of distinct numbers. The tree is heap-ordered, and an inorder traversal returns the original sequence. For example, given the sequence { 8...

2019-12-08 08:25:56 340

原创 7-3 Summit (25分)

A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit is not a simple job. The ideal arrangement of one area is to invite those heads so that everyone is ...

2019-12-08 08:23:28 223

原创 7-2 Block Reversing (25分)

Given a singly linked list L. Let us consider every K nodes as a block (if there are less than K nodes at the end of the list, the rest of the nodes are still considered as a block). Your job is to re...

2019-12-08 08:18:34 256

原创 7-1 Good in C (20分)

When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows?Input Specification:Each input file contains one test case. For each case, the first part giv...

2019-12-08 08:14:44 414

原创 2019年12月7日PAT甲级满分后记

对于我来说,PAT真的是一大执念,还好这次彻底结束,否则以后的岁月,每当我看见别人写的满分博客时,就会后悔莫及。对于我来说,在编程中已经属于老年选手。古人云:老年选手,不配拥有野心。每当我看见别人的博客写着20xx年浙大考研PAT甲级满分等字眼时,我的心情就会莫名的失落。不可否认,他们努力了,他们值得拥有。这也是我曾经的梦想,我也憧憬过,只可惜努力不够,一转身就成了笑话。我在这种自我认同感...

2019-12-07 21:35:55 1032 5

原创 7-10 Saving James Bond - Easy Version (25分)

借鉴代码注意临界值,如果007可以跳跃的长度与两个点之间的距离刚好相等,则也可以跳。这个代码对借鉴代码有点改进。#include <cstdio>#include <cmath>#include <iostream>#include <string>#include <vector>#include <cstring...

2019-12-06 11:47:40 184

原创 7-21 求前缀表达式的值 (25分)

题目描述算术表达式有前缀表示法、中缀表示法和后缀表示法等形式。前缀表达式指二元运算符位于两个运算数之前,例如2+3*(7-4)+8/4的前缀表达式是:+ + 2 * 3 - 7 4 / 8 4。请设计程序计算前缀表达式的结果值。输入格式:输入在一行内给出不超过30个字符的前缀表达式,只包含+、-、*、/以及运算数,不同对象(运算数、运算符号)之间以空格分隔。输出格式:输出前缀表达式的运算...

2019-12-06 09:25:31 977

原创 1119 Pre- and Post-order Traversals (30分)

参考代码先存着吧,以后再慢慢理解,稍微加了一点注释。柳神代码利用前序和后序判断这颗二叉树是否唯一,输出任一中序遍历。主要是左右子树的划分。除了叶子节点外,只有一个孩子节点则会导致不唯一。#include <iostream>#include <vector>using namespace std;vector<int> in, pre, pos...

2019-12-05 22:24:40 79

原创 1139 First Contact (30 分)

//26分 最后一个测试点超时#include <cstdio>#include <cmath>#include <iostream>#include <string>#include <vector>#include <cstring>#include <algorithm> #include &...

2019-12-05 11:53:22 225

原创 1149 Dangerous Goods Packaging (25 分)

版本1map映射和遍历耗时14分钟#include <cstdio>#include <cmath>#include <iostream>#include <string>#include <vector>#include <cstring>#include <algorithm> #inclu...

2019-12-03 21:02:07 150

原创 1116 Come on! Let's C (20 分)

版本1注意: 不存在的数据,就算查询过的,但是不能输出checked,而要继续输出 are you kidding?注意整型要保证输出结果为4位数,前导零需要补上。#include <cstdio>#include <cmath>#include <iostream>#include <string>#include <vecto...

2019-12-03 19:15:58 137

原创 1125 Chain the Ropes (25 分)

版本1这道题利用了哈夫曼树的性质,但是类型是double型的。输出结果的时候,是向下取整。#include <cstdio>#include <cmath>#include <iostream>#include <string>#include <vector>#include <cstring>#inclu...

2019-12-03 16:48:51 123

原创 1140 Look-and-say Sequence (20 分)

知识点:字符串 双指针版本1耗时6分钟注意使用双指针的时候,更新下标的方式。#include <cstdio>#include <cmath>#include <iostream>#include <string>#include <vector>#include <cstring>#include &lt...

2019-12-03 08:40:49 91

原创 1141 PAT Ranking of Institutions (25 分)

知识点:排序题版本1耗时46分钟注意score必须是按照整型排序,而不是浮点数排序。不然最后一个测试点会出错。#include <cstdio>#include <cmath>#include <iostream>#include <string>#include <vector>#include <cstring...

2019-12-03 08:31:10 105

原创 1153 Decode Registration Card of PAT (25 分)

版本1这个题,怎么说呢?巨TM恶心不过分吧。排序尽量用结构体吧,vector靠不住。今天不是type==3的时候,我偏要用vector保存pair类型来排序,不然早就过了。还有就是字符转数字的时候没有减去字符0,导致直接算的ASCII码值。#include <cstdio>#include <cmath>#include <iostream>#in...

2019-12-02 23:16:08 142

原创 1152 Google Recruitment (20 分)

版本1截取N位长的数字,判断是否为素数。主要不用直接用cout输出substr,因为有可能会去掉首部的前导零。#include <cstdio>#include <cmath>#include <iostream>#include <string>using namespace std;bool isprime(int n){ if...

2019-12-02 20:17:01 111

原创 1112 Stucked Keyboard (20 分)

版本1先把没坏的键标记。如果是标记坏掉的键可能出现前面的字符满足坏键,后面的字符不满足坏键的性质。#include <iostream>#include <cstdio>#include <vector>#include <cmath>#include <cstring>#include <set>#inclu...

2019-12-02 18:05:00 159

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除