L2-005 集合相似度 (25 分)(set巧用) 给定两个整数集合,它们的相似度定义为:Nc/Nt×100%。其中Nc是两个集合都有的不相等整数的个数,Nt是两个集合一共有的不相等整数的个数。你的任务就是计算任意一对给定集合的相似度。输入格式:输入第一行给出一个正整数N(≤50),是集合的个数。随后N行,每行对应一个集合。每个集合首先给出一个正整数M(≤104),是集合中元素的个数;然后跟M个[0,109...
L1-049 天梯赛座位分配 (20 分)(循环技巧) 天梯赛每年有大量参赛队员,要保证同一所学校的所有队员都不能相邻,分配座位就成为一件比较麻烦的事情。为此我们制定如下策略:假设某赛场有 N 所学校参赛,第 i 所学校有 M[i] 支队伍,每队 10 位参赛选手。令每校选手排成一列纵队,第 i+1 队的选手排在第 i 队选手之后。从第 1 所学校开始,各校的第 1 位队员顺次入座,然后是各校的第 2 位队员…… 以此类推。如果最后只剩下 1 所学校的...
求二叉树的层次遍历(前序+中序==层次) Problem Description已知一颗二叉树的前序遍历和中序遍历,求二叉树的层次遍历。Input输入数据有多组,输入T,代表有T组测试数据。每组数据有两个长度小于50的字符串,第一个字符串为前序遍历,第二个为中序遍历。Output每组输出这颗二叉树的层次遍历。Sample Input2abcbacabdecdbeacSample Output...
A - Wireless Network POJ - 2236 (并查集) An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the n...
G - Supermarket(贪心) A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of time units starting from the moment the s...
数据结构上机测试4.1:二叉树的遍历与应用1(先序+中序==后序) Problem Description输入二叉树的先序遍历序列和中序遍历序列,输出该二叉树的后序遍历序列。Input第一行输入二叉树的先序遍历序列;第二行输入二叉树的中序遍历序列。Output输出该二叉树的后序遍历序列。Sample InputABDCEFBDAECFSample OutputDBEFCAHintSource题解:根据先序和中...
B. Preparation for International Women's Day 传送门:http://codeforces.com/problemset/problem/1133/BInternational Women's Day is coming soon! Polycarp is preparing for the holiday.There are
cyk追楠神系列三(简单KMP) Problem Description众所周知,cyk给楠神写了一封信表白。作为有一个有礼貌的五好青年,楠神当然得给 cyk 写一封回信咯,俗称“好人信”。楠神是一个非常有文采的人,他在信里引用了很多名言来安慰 cyk,有时候他觉得一句话很好的话,他会引用很多次。现在他想考考 cyk,在告诉 cyk 里面每句名言的情况下,看看 cyk 能不能找到每局名言在信里被引用了多少次。如果能找到的话...
D. Almost All Divisors We guessed some integer numberxx. You are given a list ofalmost allits divisors.Almost allmeans that there areall divisors except11andxxin the list.Your task is to find the minimum possible...
数据结构实验之二叉树三:统计叶子数 Problem Description已知二叉树的一个按先序遍历输入的字符序列,如abc,,de,g,,f,,, (其中,表示空结点)。请建立二叉树并求二叉树的叶子结点个数。Input连续输入多组数据,每组数据输入一个长度小于50个字符的字符串。Output输出二叉树的叶子结点个数。Sample Inputabc,,de,g,,f,,,Sample Output...
L3-010 是否完全二叉搜索树 (30 分) 将一系列给定数字顺序插入一个初始为空的二叉搜索树(定义为左子树键值大,右子树键值小),你需要判断最后的树是否一棵完全二叉树,并且给出其层序遍历的结果。输入格式:输入第一行给出一个不超过20的正整数N;第二行给出N个互不相同的正整数,其间以空格分隔。输出格式:将输入的N个正整数顺序插入一个初始为空的二叉搜索树。在第一行中输出结果树的层序遍历结果,数字间以1个空格分隔,行的首尾不得有多...
A. Regular Bracket Sequence(思维) A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by i...
高斯消元 //高斯消元 时间复杂度O(n^3) 使用浮点数计算#include<iostream>#include<string.h>#include<math.h>using namespace std;const double eps=1e-8;const int maxn=101;double a[maxn][maxn];bool l[maxn];...
w #include<bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=100010;int a[maxn],dp[maxn][2];vector<int>G[maxn];void DFS(int u,int pre){ for(int i=0;i<G[u]....
KMP #include <stdio.h>#include <stdlib.h>#include<map>#include<algorithm>#include<iostream>#include<bits/stdc++.h>using namespace std;typedef long long ll;cons...
E - A New Function LightOJ - 1098 We all know that any integer number n is divisible by 1 and n. That is why these two numbers are not the actual divisors of any numbers. The function SOD(n) (sum of divisors) is defined as the summati...
D - Nim POJ - 2068 (记忆化搜索) Let's play a traditional game Nim. You and I are seated across a table and we have a hundred stones on the table (we know the number of stones exactly). We play in turn and at each turn, you or I can ...