- 博客(16)
- 资源 (3)
- 收藏
- 关注
原创 简单的迷宫问题
链接:https://www.nowcoder.com/acm/contest/93/D 来源:牛客网 题目描述 给你一个n*m的迷宫,这个迷宫中有以下几个标识: s代表起点 t代表终点 x代表障碍物 .代表空地 现在你们涵哥想知道能不能从起点走到终点不碰到障碍物(只能上下左右进行移动,并且不能移动到已经移动过的点)。 输入描述: 输入第一行一个整数T(1<=T<=...
2018-04-05 17:00:05 1151 1
原创 快排+二分
#include<iostream> using namespace std; int s1[1002]; int temp; void quick_sort(int left,int right) { if(left>right) return ; int i=left; int j=right; int temp=s1[left]; while(i!=j) { ...
2018-04-29 21:35:38 299
原创 思维 ZOJ 3872 Beauty of Array
Edward has an array A with N integers. He defines the beauty of an array as the summation of all distinct integers in the array. Now Edward wants to know the summation of the beauty of all contiguous ...
2018-04-29 18:32:21 112
原创 pair
4、编程实践 练习:编写程序读入一系列string和int型数据,将每一组存储在一个pair对象中,然后将这些pair对象存储在vector容器 #include<iostream> #include<string> #include<vector> #include<utility> using namespace std; int main...
2018-04-29 08:01:02 1065
原创 啦啦啦
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 100000+100; int T,n,m; LL d[maxn]; struct node{ int u; LL c; bool operator<(const node&am...
2018-04-28 22:36:11 86
原创 快速排序
#include<iostream> #include<cstdio> using namespace std; int s[1005]; void quick_sort(int left,int right) { if(left>right)//一定时left>right,不能写成left==right return ; int i=left; in...
2018-04-23 22:34:26 97
原创 N阶乘的位数(斯特林公式)
#include<cstdio> #include<iostream> #include<cmath> using namespace std; int main() { int a,n; double sum; cin>>n; for(int i=1;i<=n;i++) { s...
2018-04-17 17:29:58 663
原创 N求大数阶乘!
#include<cstdio> #include<iostream> int s1[100005];//不知道为什么数组定义在外面运行就会非常慢,定义在main里面就运行的快多了。 using namespace std; int main() { int a; //scanf("%d",&a); cin>>a; int temp; in...
2018-04-17 17:14:42 143
原创 dijkstra最短路算法模板(双源)
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> using namespace std; int vis[1005],dis[1005],cost[1005][1005];//vis为标记跳板点,dis为每个点与起点的距离,cost为记录点与点的权值,...
2018-04-16 21:31:32 729
原创 dijkstra最短路经算法简单模板(单源)
Bessie 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 the morning milking. Bessie needs her beauty sleep, so she wants to get b...
2018-04-13 15:43:30 260
原创 最长公共子序列
最长公共子序列 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 咱们就不拐弯抹角了,如题,需要你做的就是写一个程序,得出最长公共子序列。 tip:最长公共子序列也称作最长公共子串(不要求连续),英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,...
2018-04-12 11:44:25 91
原创 vector的简单操作
链接:https://www.nowcoder.com/acm/contest/93/L来源:牛客网共有T(T<=10)组数据,每组数据第一行为两个数 N, M (N,M <= 500000),代表有N只天鹅和M次操作,接下来一行是N个数字,下面M行首先会输入一个字符串S,接着会有三类操作,如果S是“insert”,接着输入一个正整数a,代表插入一只“萌”值为a的天鹅,如果S是“del...
2018-04-05 18:38:39 145
原创 阶乘分解因式
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int main() { int a,b,c,t,n; cin>>n; while(n--) { cin>>a>>b; while(a>0) { ...
2018-04-03 22:23:11 257
原创 神奇的记录方式(map)
#include<iostream> #include<cstdio> #include<cstring> #include<map> using namespace std; int main() { int a,b,c,d,n,m,t,sum=0.0; char ch1,ch2,ch; cin>>n; while(n--) ...
2018-04-03 16:13:20 94
原创 动态规划
步骤描述最优解的结构递归定义最优解的值按自底向上的方式计算最优解的值由计算出的结果构造一个最优解vector<int> vec;在vector的使用方法中,不能直接定义int i =vec.begin();...
2018-04-01 20:24:21 70
原创 杭电(2089)(打表)
#include<iostream>#include<algorithm>#include<cstdio> using namespace std;int s[1000005];int main(){ int a,b; s[1]=1; for( int i=2;i<1000005;i++) { int j=1,k=i; w...
2018-04-01 17:06:58 234
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人