├── 2016A.cpp ├── 2016B.cpp ├── 2016C.cpp ├── 2016D.cpp ├── 2017A.cpp ├── 2017C.cpp ├── 2017D.cpp ├── 2018-1-A.cpp ├── 2018-1-B.cpp ├── 2018-1-C.cpp ├── 2018-2-A.cpp ├── 2018-2-B.cpp ├── 2018-2-C.cpp ├── 2018-3-A.cpp ├── 2018-3-B.cpp ├── 2018-3-C.cpp └── README.md /2016A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define N 10000+5 3 | using namespace std; 4 | 5 | int A[N]; 6 | 7 | int main() 8 | { 9 | int n; 10 | 11 | while(~scanf("%d",&n)){ 12 | int ans=0; 13 | int cur_max = 0; 14 | for(int i=0;i>A[i]; 16 | } 17 | for(int i=0;i 2 | #include 3 | 4 | #define N 100+5 5 | using namespace std; 6 | 7 | 8 | int A[N]; 9 | 10 | int solve(int n){ 11 | 12 | int ans=0; 13 | 14 | for(int i=0;i=lb){ 27 | ans += rb-lb+1; 28 | } 29 | } 30 | } 31 | 32 | return ans; 33 | 34 | } 35 | 36 | 37 | int main() 38 | { 39 | 40 | int n; 41 | while(~scanf("%d",&n)){ 42 | for(int i=0;i>A[i]; 44 | sort(A,A+n); 45 | 46 | cout< 5 | #define N 10 + 5 6 | #define M 100000+5 7 | 8 | using namespace std; 9 | 10 | int Num[N],Val[N]; 11 | int dp[M]; 12 | 13 | int main() 14 | { 15 | int n,Cmax; 16 | while(~scanf("%d%d",&n,&Cmax)){ 17 | 18 | for(int i=1;i<=n;i++) 19 | cin>>Num[i]>>Val[i]; 20 | 21 | for(int i=0;i<=Cmax;i++) 22 | dp[i] = 0; 23 | 24 | for(int i=1;i<=n;i++){ 25 | for(int k=1;Num[i]-k>=0;k*=2){//二进制编码 26 | for(int j=Cmax;j>=Val[i]*k;j--){ 27 | dp[j] = max(dp[j],dp[j-Val[i]*k]+Val[i]*k); 28 | } 29 | 30 | Num[i] -= k; 31 | 32 | } 33 | if(Num[i]>0){ 34 | for(int j=Cmax;j>=Val[i]*Num[i];j--){ 35 | dp[j] = max(dp[j],dp[j-Val[i]*Num[i]]+Val[i]*Num[i]); 36 | } 37 | } 38 | } 39 | for(int i=0;i<=Cmax;i++) 40 | cout<[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2016A.cpp) 7 | 8 | - B.无向图最长单源路径[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2016B.cpp) 9 | 10 | - C.表示式求值:形如(3*2+3/5)+1*5[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2016C.cpp) 11 | 12 | - D.求树上最长的路径长度[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2016D.cpp) 13 | 14 | ### 2017 15 | 16 | - A.给定一个n层的满二叉树,不存在的结点用-1表示,同时给定一个sum,问从根结点到达叶节点有哪些路径使得点权和刚好为sum。从左到右输出所有满足条件的路径。[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2017A.cpp) 17 | 18 | - B.给定n个非负的整数,每个数代表这个数可以跳跃的最远距离,同时每个数字之间的距离已知,问能不能从最左边的点跳到最右边[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2017B.cpp) 19 | 20 | - C.给定由IF,THEN,ELSE,BEGIN,END构成的一组语句,判断该语句的嵌套结构是否符合语法规范[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2017C.cpp) 21 | 22 | - D.给定一组数,问从给定的数组中选取3个数作为三角形的不同边,一共有多少中符合条件的选法[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2017D.cpp) 23 | 24 | ### 2018 25 | 26 | (南京市内高校) 27 | - A.给出一个多叉树(多于二叉)的先序遍历和后序遍历,(每个节点以字符串标识),求该树的深度。没有数据范围.[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2018-1-A.cpp) 28 | 29 | - B.第二题:给出初始单词,终止单词,以及词典,所有单词均为长度相等的小写字母串,求从初始单词变换到终止单词的路径长度。每次变换只允许改变一个字符,且所有中间单词只能是词典中的,若不能做到则输出0。样例:
30 | hit
31 | cog
32 | hot dot dog cog dig 33 | 该样例中hit hot dot dog cog路径长度为5. 34 | 数据范围:词典单词数<=20000,串长度<=5. 35 | [here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2018-1-B.cpp) 36 | - C.第三题:一台机器有ni张面值为ki的纸币,给定一个c,求小于等于c的一个最大金额,使得机器能恰好给出。数据范围:C<=100000,ni<=1000,ki<=1000,种类数<=10.[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2018-1-C.cpp) 37 | 38 | (南京市外高校) 39 | 第一组 40 | - A.Count number of binary strings without consecutive 1’s Given a positive integer n(3≤n≤90), count all possible distinct binary strings of length n such that there are no consecutive 1's . 41 | Input: 2
42 | Output: 3 // The 3 strings are 00, 01, 10 43 | Input: 3
44 | Output: 5 // The 5 strings are 000, 001, 010, 100, 101 45 | [here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2018-2-A.cpp) 46 | 47 | - B.给定一个二维的矩阵,包含 'X' 和 'O'(字母 O)。找到所有被 'X' 围绕的区域,并将这些区域里所有的 'O' 用 'X' 填充。被围绕的区间不会存在于边界上,换句话说,任何边界上的 'O' 都不会被填充为 'X'。 任何不在边界上,或不与边界上的 'O' 相连的 'O' 最终都会被填充为 'X'。如果两个元素在水平或垂直方向相邻,则称它们是“相连”的。[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2018-2-B.cpp) 48 | 49 | - C.双向LIS [POJ1836](http://poj.org/problem?id=1836)[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2018-2-C.cpp) 50 | 51 | 第二组 52 | 53 | - A.给定正整数n(n≤40),从1到n中随机选择n-1个数,并将它们以随机顺序连接为字符串s,这意味着在1和n之间有一个缺失的数字。你能找到那个缺失的数字吗?(请注意在某些情况下答案不唯一,此时你只需要找到一个有效的答案。)[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2018-3-A.cpp) 54 | 55 | - B.动态规划[poj1018](http://poj.org/problem?id=1018)[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2018-3-B.cpp) 56 | 57 | - C.最大子矩阵问题[poj1050](http://poj.org/problem?id=1050)[here](https://github.com/SaulZhang/NJU-Summary-Vocation-Camp-OJ/blob/master/2018-3-C.cpp) 58 | --------------------------------------------------------------------------------