10 2018 档案
摘要:链接:POJ - 1276 题意:给你一个最大金额m,现在有n种类型的纸票,这些纸票的个数各不相同,问能够用这些纸票再不超过m的前提下凑成最大的金额是多少?题解:写了01背包直接暴力,结果T了,时间复杂度太高了,要跑外循环m和内循环所有的纸票的个数。这个题需要把每种纸...
阅读全文
摘要:AE 简单的复数运算(类和对象) (SDUT 4303)import java.util.*;class Complex { int a, b; Complex() { } Complex(int n, int m) { a = n; b = m; } void...
阅读全文
摘要:二分匹配——最大匹配#include #include #include #include #include using namespace std;const int maxn = 300;vectorE[maxn];int used[maxn];int match...
阅读全文
摘要:题目描述飞行大队有若干个来自各地的驾驶员,专门驾驶一种型号的飞机,这种飞机每架有两个驾驶员,需一个正驾驶员和一个副驾驶员。由于种种原因,例如相互配合的问题,有些驾驶员不能在同一架飞机上飞行,问如何搭配驾驶员才能使出航的飞机最多。因为驾驶工作分工严格,两个正驾驶员或两个...
阅读全文
摘要:HDU - 1532题意:有m个点,n条管道,问从1到m最大能够同时通过的水量是多少?题解:最大流模板题。#include #include #include #include #include using namespace std;typedef long lon...
阅读全文
摘要:ProblemA sequence of N positive integers (10 #include using namespace std;typedef long long ll;const int maxn = 1000005;int a[maxn];in...
阅读全文
摘要:The 2014 ACM-ICPC Asia Mudanjiang Regional Contest昨晚做了训练赛,然后读题又自闭了QAQ。Average ScoreZOJ - 3819题意:给你两个班级A、B的人数分别是n、m,告诉你n-1、和m个人的成绩,然后让你...
阅读全文
摘要:康托展开康托展开,用人话说出来..就是把一个数组的多种排序情况对应用数字表示出来公式:X = a[i] * (n-1)! + a[i-1] * (n-2)! + … + a[1] * 0!其中a[i]表示后面比该元素小的元素的个数举个例子,有5个数1 2 3 4 5共...
阅读全文
摘要:#include using namespace std;typedef long long ll;char s[100];char a[100];int main(){ int i,j,k,f,top,len; while(gets(s) != '\0'...
阅读全文
摘要:迪杰斯特拉简单版#include using namespace std;int m,n;const int inf = 0x3f3f3f3f;int dis[1005];int gra[405][405];int vis[1005];void dj(int s, i...
阅读全文
摘要:某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。In...
阅读全文
摘要:problemBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for ...
阅读全文
摘要:#include using namespace std;const int maxn = 50005;int num = 0;struct node{ int *elem; int len;};void Creatlist(struct node &li...
阅读全文
摘要:P 3-1 Point类的构造函数 (SDUT 2670)import java.util.Arrays;import java.util.Scanner;public class Main { public static void main(String[] ...
阅读全文
摘要:ProblemYou have just bought a new house, and it has a huge, beautiful lawn. A lawn that needs cutting. Several times. Every week. The ...
阅读全文
摘要:ProblemRecall that a subsequence of a string is any string obtained by removing some subset of characters from the string, for instanc...
阅读全文
摘要:#include#includeusing namespace std;#define nc getcharint n,q;bitset S[10002];/*快速输入*/inline int red(){ int res=0,f=1;char ch=nc();...
阅读全文
摘要:bitset定义与初始化bitset是STL提供的用于记录01串的容器也就是bitset的每个元素只能为0/1用bitset之前别忘了: #include1以下是正确的定义方式: bitset a; //第0~15位都是0bitset b(string("01001...
阅读全文
摘要:& 与 (都是1时,结果才为1)表示按位与。&表示按位与操作,我们通常使用0x0f来与一个整数进行&运算,来获取该整数的最低4个bit位,例如,0x31 & 0x0f的结果为0x01。二进制与运算规则:1&1=1 1&0=0 0&0=0| 或 (只要有1,那么就...
阅读全文
摘要:bitset存储二进制数位。bitset就像一个bool类型的数组一样,但是有空间优化—bitset中的一个元素一般只占1 bit,相当于一个char元素所占空间的八分之一。bitset中的每个元素都能单独被访问,例如对于一个叫做foo的bitset,表达式foo[3...
阅读全文
摘要:K 正方形(SDUT 2444)import java.lang.reflect.Array;import java.util.*;public class Main { public static void main(String[] args) { S...
阅读全文
摘要:G 织女的红线(SDUT 2240)import java.util.Scanner;import java.text.DecimalFormat;class Sum { double x1, y1, x2, y2; Sum(double n1, double ...
阅读全文
摘要:#include using namespace std;int a[1000006];int b[1000006];int sta[100006];int main(){ int t,n,i,j,top; while(~scanf("%d",&t)) ...
阅读全文
摘要:#include using namespace std;int a[1005];int main(){ int t,n,i,j; while(~scanf("%d",&t)) { while(t--) { ...
阅读全文
摘要:题解:把每一步计算的答案再存在栈里面,直到计算结束。 如果是操作数 那么直接入栈;如果是运算符,那么把栈里面最顶部的两个操作数拿出来进行运算,运算结果再放入到栈里面,计算完所有的(#之前的长度位len- 1)就可以了。#include using n...
阅读全文
摘要:题目链接#include using namespace std;typedef long long ll;int ok(char ch, char sh){ if(sh == '(')return 1; if((ch == '*' || ch == '/...
阅读全文
摘要:题目链接题解: 特判一下n==0的时候。#include using namespace std;int a[1000];int main(){ int top = 0; int n,r; scanf("%d",&n); scanf("%d",...
阅读全文
摘要:#include using namespace std;typedef struct node{ int data2; int data1;//mu struct node *next;} ;int main(){ int n; str...
阅读全文
摘要:#include using namespace std;typedef struct node{ int data; struct node *next, *last;} Node;int main(){ int n, m, a; scanf...
阅读全文
摘要:#include using namespace std;typedef struct node{ int data; struct node *next, *last;} Node;int main(){ int n, m, a; scanf...
阅读全文
摘要:#include using namespace std;typedef struct node{ int data; struct node *next, *last;} Node;int main(){ int n, m, a; scanf...
阅读全文
摘要:#include using namespace std;typedef struct node{ int data; struct node* next;} Node;Node* Createlist(int n){ Node* head,*p; ...
阅读全文
摘要:#include using namespace std;typedef struct node{ int data; struct node* next;} Node;Node* Createlist(int n){ Node* head,*p; ...
阅读全文
摘要:#include using namespace std;struct node{ int data; struct node *next;};int main(){ int n; struct node *head,*tail,*p,*q,*...
阅读全文
摘要:#include using namespace std;struct node{ int data; struct node *next;};int main(){ int n; struct node *head,*tail,*p,*q,*...
阅读全文
摘要:#include using namespace std;struct node{ int data; struct node *next;};struct node *crea(int n){ int i; struct node *head...
阅读全文
摘要:#include using namespace std;struct node{ int data; struct node *next;};struct node *crea(int n){ int i; struct node *head...
阅读全文
摘要:#include using namespace std;struct node{ int data; struct node *next;};struct node *crea(int n){ int i; struct node *head...
阅读全文
摘要:#include using namespace std;struct node{ int data; struct node *next;};struct node *creat(int n) { struct node *head,*...
阅读全文
摘要:#include using namespace std;struct node{ int data; struct node *next;};struct node *creat(int n) { struct node *head,*...
阅读全文
摘要:题目链接题解:用二分查询一下每次满足长度的下一个加上它的长度。#include using namespace std;typedef long long ll;ll a[500005];ll b[500005] = {0};int main(){ ll n,i...
阅读全文
摘要:lower_bound( )和upper_bound( )都是利用二分查找的方法在一个排好序的数组中进行查找的。在从小到大的排序数组中,lower_bound( begin,end,num):从数组的begin位置到end-1位置二分查找第一个大于或等于num的数字,...
阅读全文
摘要:题目链接#include using namespace std;typedef long long ll;int a[200005]; //存放原始数据int vis[200005]; //标记选的对手int b[200005]; //答案序列queueq; /...
阅读全文
摘要:题目链接:Central Europe Regional Contest 2015 Zagreb, November 13-15, 2015D、Digit Division(排列组合+思维)题解:如果这个数从划分的过程中第一、二道竖线前的能够整除m,那么第一道与第二道...
阅读全文
摘要:QWQ请假一节课,错过一章内容,只能求助qsh了。C/C++训练1---最大公约数与最小公倍数(SDUT 1131)import java.util.*;class Number { int a, b; Number(int n, int m) { a = n; ...
阅读全文
摘要:题目链接#include using namespace std;struct node{ int data; struct node *next;};int main(){ int n; struct node *head,*p; he...
阅读全文
摘要:题目链接#include using namespace std;struct node{ int data; struct node *next;};int main(){ int n; struct node *head,*p; he...
阅读全文
摘要:Problem Description输入N个整数,按照输入的顺序建立单链表存储,并遍历所建立的单链表,输出这些数据。Input第一行输入整数的个数N;第二行依次输入每个整数。Output输出这组整数。Sample Input8 12 56 4 6 55 15 33 ...
阅读全文