- 博客(19)
- 收藏
- 关注
原创 异或、与、或、左移运算符、右移运算符
^ XOR运算符 异或运算 0^0=0;0^1=1;1^0=1;1^1=0& 与运算 0&0=0;0&1=0;1&0=0;1&1=1;| 或运算 0|0=0;1|0=1;0|1=1;1|1=1;这些三个都是位运算。系统将两者二进制的右侧对齐后运算。一般我们用的正数,正数会在不够长的左边补上0,如:1|41=001(2进制)4=100(2进制)所以1|4=101(二进制)=5(10进制)<< 左移运算符 将a的二进制左移 a=a<
2022-03-01 18:56:45
372
原创 Equals
题目:Problem StatementWe have a permutation of the integers from11throughNN,p_1p1,p_2p2, ..,p_NpN. We also haveMMpairs of two integers between11andNN(inclusive), represented as(x_1,y_1)(x1,y1),(x_2,y_2)(x2,y2), ..,(x_M,y_M)(xM,yM)...
2022-02-27 11:43:21
558
原创 Cow Contest
题目:FJ的N(1 <= N <= 100)头奶牛们最近参加了场程序设计竞赛:)。在赛场上,奶牛们按1..N依次编号。每头奶牛的编程能力不尽相同,并且没有哪两头奶牛的水平不相上下,也就是说,奶牛们的编程能力有明确的排名。 整个比赛被分成了若干轮,每一轮是两头指定编号的奶牛的对决。如果编号为A的奶牛的编程能力强于编号为B的奶牛(1 <= A <= N; 1 <= B <= N; A != B) ,那么她们的对决中,编号为A的奶牛总是能胜出。 FJ想知道奶牛们编程能力的具体排
2022-02-27 11:32:57
190
原创 单源最短路
题目描述给一个n(1 \leq n \leq 2500)n(1≤n≤2500)个点m(1 \leq m\leq 6200 )m(1≤m≤6200)条边的无向图,求ss到tt的最短路。输入格式第一行四个由空格隔开的整数nn、mm、ss、tt。之后的mm行,每行三个正整数s_isi、t_iti、w_i(1 \leq w_i \leq 10 ^ 9)wi(1≤wi≤109),表示一条从s_isi到t_iti长度为w_iwi的边。输出格式...
2022-02-27 11:16:36
631
原创 ..食物链
题目:如图所示为某生态系统的食物网示意图,据图回答此题。现在给你nn个物种和mm条能量流动关系,求其中的食物链条数。物种的名称为从11到nn的编号。mm条能量流动关系形如a_1a1b_1b1a_2a2b_2b2a_3a3b_3b3… …a_mamb_mbm其中a_i \ b_iaibi表示能量从物种a_iai流向物种b_ibi。注意单独的一种孤立生物不算一条食物链。输入格式第一行两个整数nn和mm...
2022-02-27 10:12:01
739
原创 Buy Tickets
题目:Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue…The Lunar New Year was approaching, but unluckily the Little Cat still had schedules going here and there. Now, he had to travel
2022-02-27 09:45:39
113
原创 GDUT-寒假专题训练5--Count Color
题目:Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem.There is a very long board with length L centimeter, L is a positive integer, so we can evenly divide the boa
2022-02-27 09:30:36
240
原创 线段树区间修改
区别上一篇的单点修改,区间修改令ll=1,rr=1同样可以实现单点修改#include <iostream>#include <string>#include <cstdlib>#include <vector>#include <algorithm>#include <iomanip>using namespace std;int a[10000]={},b[10000],lazy[200020];inline
2022-02-23 17:21:51
284
2
转载 快读样本子程序
inline int read(){ int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();} while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar(); return s*w;}只能读入数字,若要读入到a中,直接a=read();即可...
2022-02-23 16:29:06
122
原创 线段树的查询与单点修改与建树
#include <iostream>#include <string>#include <cstdlib>#include <vector>#include <algorithm>#include <iomanip>using namespace std;int a[20]={},b[20];inline void push(int xb)//将子节点的两个值上传{ b[xb]=b[xb*2]+b[xb*2+1.
2022-02-23 16:21:43
480
原创 GDUT-寒假专题训练4--Combinations
题目:Computing the exact number of ways that N things can be taken M at a time can be a great challenge when N and/or M become very large. Challenges are the stuff of contests. Therefore, you are to make just such a computation given the following:GIVEN:
2022-02-23 14:34:44
414
原创 GDUT-寒假专题训练5--Lost Cows
题目:N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, they visited the neighborhood 'watering hole' and drank a few too many beers before dinner. When it was time to line up for their evening mea
2022-02-23 14:18:36
210
原创 GDUT-寒假专题训练4--k-rounding
For a given positive integerndenote itsk-rounding as the minimum positive integerx, such thatxends withkor more zeros in base10and is divisible byn.For example,4-rounding of375is375·80 = 30000.30000is the minimum integer such that it end...
2022-02-23 13:44:13
288
原创 GDUT-寒假专题训练3--Networking
Problem StatementThere areNNtowns on a plane. Theii-th town is located at the coordinates(x_i,y_i)(xi,yi). There may be more than one town at the same coordinates.You can build a road between two towns at coordinates(a,b)(a,b)and(c,d)(c,d)for...
2022-02-23 11:50:14
530
原创 GDUT-寒假专题训练3--The Suspects
题目:2019冠状病毒病(英语:Coronavirus disease 2019,缩写:COVID-19 ),是一种由严重急性呼吸系统综合症冠状病毒2型(缩写:SARS-CoV-2)引发的传染病。此病在全球各国大规模爆发并急速扩散,成为人类历史上致死人数最多的流行病之一。 很显然,目前最好的办法就是将所有可能的患者都隔离起来。 现在某高校正在排查可能的患者,这个高校中有多个社团,每个社团经常进行内部交流,一名学生可能会加入多个社团。学校认为一旦某个社团里出现一名可疑患者,这整个社团的学生都被视为是可能的
2022-02-23 11:20:59
185
原创 GDUT-寒假专题训练2--采药
题目:辰辰是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师。为此,他想拜附近最有威望的医师为师。医师为了判断他的资质,给他出了一个难题。医师把他带到一个到处都是草药的山洞里对他说:“孩子,这个山洞里有一些不同的草药,采每一株都需要一些时间,每一株也有它自身的价值。我会给你一段时间,在这段时间里,你可以采到一些草药。如果你是一个聪明的孩子,你应该可以让采到的草药的总价值最大。”如果你是辰辰,你能完成这个任务吗?输入格式第一行有两个整数 TT(1 \le T \le 10001≤T≤1000
2022-02-22 18:16:19
169
原创 GDUT-寒假专题训练2--最长公共子序列
题目:给出1∼n 的两个排列P1 和 P2,求它们的最长公共子序列。输入格式第一行是一个数 n (1≤n≤105)。接下来两行,每行为 n 个数,为自然数 1∼n 的一个排列。输出格式一个数,即最长公共子序列的长度。样例1输入:53 2 1 4 51 2 3 4 5样例1输出:3题解:这道题其实是考最大上升子序列。用动态规划的做法来做的话会超时。动态规划的话用一个二维数组p[i][j]标记在第一行取i个第二行取j个字母时的最大公共子序列长度。有当p1[i.
2022-02-22 17:58:07
309
原创 GDUT-寒假专题训练1--二分查找
题目:给定一个严格单调的数列,询问若干个数分别需要在数列中二分几次才能找到。如果能找到,输出二分的次数;如果不能找到,输出NONE。二分查找参考程序如下:(数列单调递增时)l = 1, r = n, cnt = 0;while (l <= r) { mid = (l + r) / 2; cnt++; if (a[mid] == key) break; if (a[mid] > key) r = mid - 1; else l = mid .
2022-02-22 16:54:10
372
原创 GDUT-寒假专题训练1--马走日
题目:马在中国象棋以日字形规则移动。请编写一段程序,给定 n \times mn×m大小的棋盘,以及马的初始位置 (x, y)(x,y),要求不能重复经过棋盘上的同一个点,计算马可以有多少途径遍历棋盘上的所有点。输入格式第一行为整数T(T < 10)T(T<10),表示测试数据组数。每一组测试数据包含一行,为四个整数,分别为棋盘的大小以及初始位置坐标n,m,x,yn,m,x,y。(0 \le x \le n-1,0 \le y \le m-1, m < 10, n &..
2022-02-22 16:42:16
548
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅