
考研复试题
notmuch
这个作者很懒,什么都没留下…
展开
-
UVA - 10037
别人写的题解:https://blog.youkuaiyun.com/qq_42505741/article/details/84852078做这道题应该要有个感觉,是有个迭代或规律的。没思路时可以枚举一下,应该枚举到n=4就可以得出个思路了。#include<cstdio>#include<iostream>#include<algorithm>#include...原创 2020-05-07 18:39:26 · 210 阅读 · 0 评论 -
UVA-120
模拟题。#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>#include<stack>#include<queue>using namespace std;const int maxn=1e2+6;typedef lo...原创 2020-05-02 23:26:36 · 176 阅读 · 0 评论 -
牛客-计算机复试题-求图的连通分支数
求图的连通分支数可以用并查集实现。并查集的讲解推荐:https://blog.youkuaiyun.com/liujian20150808/article/details/50848646本题求的是无向图的连通分支数,用Python代码实现如下:"""无向或有向图的连通分治数可以用并查集求出来。并查集的本质是将图分成多棵树,每棵树是每个连通分支的树形表示,因此树的总数等于连通分支的总数并查集需...原创 2020-04-03 16:49:57 · 2520 阅读 · 0 评论 -
牛客-计算机复试题-Day of Week
语言是python。这题应该有一个很简单的方法,就是用库,不过我没去试,是自己推出来的。在写这篇博客的时候是2020.3.30,星期一,则得到下表:2020.3.30星期一2020.3.31星期二2020.4.1星期三2020.4.2星期四2020.4.3星期五2020.4.4星期六2020.4.5星期日原理就...原创 2020-03-30 18:34:33 · 210 阅读 · 0 评论 -
牛客-计算机复试题-Sum of Factorials
递归求解即可,一开始忘了考虑 0! 的情况,WA了几次。。def DFS(left, right, tmp_value, target): if tmp_value == target: return True if left >= right or tmp_value > target: return False for i ...原创 2020-03-13 10:00:04 · 147 阅读 · 0 评论 -
牛客-计算机复试-数字反转
被样例坑了两次。。212 3499 1最开始那个2是没有的。while True: try: num1, num2 = input().strip().split() str1 = str(int(num1[::-1]) + int(num2[::-1])) str2 = str(int(num1) + int(num2))[::...原创 2020-03-08 23:12:52 · 170 阅读 · 0 评论 -
牛客-计算机复试-Old Bill
两层循环,倒序枚举就好。while True: try: N = int(input().strip()) line = input().strip().split() middle = 0 for number in line: middle = middle*10 + int(number) ...原创 2020-03-08 22:20:51 · 226 阅读 · 0 评论 -
牛客-计算机复试-Simple Sorting
用python非常简单的就解决了。while True: try: N = int(input().strip()) line = input().strip().split() array = sorted(list(set([int(number) for number in line]))) for i in ran...原创 2020-03-08 21:22:46 · 125 阅读 · 0 评论 -
牛客-计科复试题-WERTYU
用python很方便就能解决这道题:字典+zip()。可能有更好的方案。right_to_left = {}a1 = ['`'] + [str(digit) for digit in range(1, 10)] + ['0', '-', '=']a1 = dict(zip(a1[1:], a1[:-1]))a2 = ['~', '!', '@', '#', '$', '%', '^',...原创 2020-03-04 13:21:34 · 220 阅读 · 1 评论 -
牛客-计算机历年考研复试上机题-成绩排序
其实很简单,但是本人刚接触Python,对Python还很陌生,所以就实现起来还是遇到了困难,主要是排序那块。版本一,直接用sort()方法就好了,Python排序的内部实现是稳定的,因此相对顺序不会变。class Student(object): def __init__(self, name=None, scores=0, order=0, m=0): sel...原创 2020-02-29 21:43:48 · 314 阅读 · 0 评论 -
牛客-计算机历年考研复试上机题-反序输出
python利用字符串切片的方法,可以很方便的实现反序输出。while True: try: string = input().strip() print(string[::-1]) except: break```原创 2020-02-29 22:00:11 · 187 阅读 · 0 评论 -
牛客-计算机考研复试上机题-二次方程计算器
这道题其实考察的是对字符串的处理。显然我们要将方程化为ax2+bx+c=0的形式,因此可以找出式子中所有x2、x的系数以及c。但是题目的输入是一个完整的字符串,如果暴力遍历的话会很麻烦,于是就想到把式子中的x2, x, c分开来。这用python其实很方便(其他语言不清楚,C/C++可能暴力会更简单)。用python 40+行就能解决这道题。def getNumber(string, st...原创 2020-03-03 13:29:51 · 412 阅读 · 0 评论