自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(81)
  • 收藏
  • 关注

原创 工资计算

#include <bits/stdc++.h>using namespace std;const int INF = 1000000000;//2) A中不超过1500元的部分,税率3%;//  3) A中超过1500元未超过4500元的部分,税率10%;//  4) A中超过4500元未超过9000元的部分,税率20%;//  5) A中超过9000元未超过35000元的部分,税率25%;//  6) A中超过35000元未超过55000元的部分,税率30%;//  7) A

2021-03-02 11:13:22 165

原创 火车购票

#include <bits/stdc++.h>using namespace std;const int maxn = 22;int empty[maxn];const int N = 20;int main(){ for(int i=0; i<N; ++i) empty[i] = 5; int n; scanf("%d", &n); for(int k=0; k<n; ++k){ int p; scanf("%d", &p); boo

2021-03-02 10:19:29 116

原创 消除类游戏

#include <bits/stdc++.h>using namespace std;int n, m;const int maxn = 35;int board[maxn][maxn];struct Pos{ int x, y; Pos(int xx, int yy): x(xx),y(yy) {}};vector<Pos> v;int main(){ memset(board,0,sizeof(board)); scanf("%d%d", &n,

2021-03-02 09:43:53 141

原创 俄罗斯方块

#include <bits/stdc++.h>using namespace std;const int maxR = 15;const int maxC = 10;const int N = 4;int board[maxR+1][maxC];int block[N][N];struct Pos{ int x, y; Pos(int xx, int yy):x(xx),y(yy) {}};vector<Pos> v;int main(){ memset(

2021-03-02 09:23:10 109

原创 小明种苹果

#include <bits/stdc++.h> using namespace std;const int maxn = 1000 + 5;int flag[maxn] = {0};int main(){ int n, m, sum, a, t=0, d=0, e=0; scanf("%d", &n); for(int i=0; i<n; ++i){ scanf("%d%d", &m,&sum); for(int j=2; j<=m;

2021-03-01 09:32:13 93

原创 回收站选址

#include <bits/stdc++.h> using namespace std;const int maxn = 4;int cnt[maxn+1] = {0};vector<pair<int,int>> p;map<pair<int,int>, int> ps;int n;int main(){ scanf("%d", &n); for(int i=0; i<n; ++i){ int x, y;

2021-03-01 09:15:54 92

原创 正则表达式

//查找不在字符c之后的字符串ei string pattern("[^c]ei"); //包含pattern的整个单词 pattern = "[[:alpha:]]*" + pattern + "[[:alpha:]]*"; regex r(pattern); //构造一个用于查找模式的regex smatch results; //定义一个对象保存搜索结果 //定义一个string保存与模式匹配和不匹配的文本 string test_str = "receipt freind t.

2021-02-25 20:11:39 116

原创 ccf最大的矩形

#include <bits/stdc++.h> using namespace std;const int maxn = 1000 + 5;int h[maxn];int main(){ int n; scanf("%d", &n); for(int i=0; i<n; ++i) scanf("%d", &h[i]); int ans = 0; for(int i=0; i<n; ++i){ int minh = h[i]; for(int

2021-02-25 10:50:42 88

原创 uva10976

#include<cstdio>#include<vector>using namespace std;int main() { int k; while(scanf("%d", &k) == 1 && k) { vector<int> X, Y; //存储每一对x和y for(int y = k+1; y <= k*2; y++) { //在k+1和2*k范围内枚举y,根据y计算出x //

2021-02-25 10:30:57 90

原创 uva11059

#include<iostream>using namespace std;int main() { int S[20], kase = 0, n; while(cin >> n && n) { for(int i = 0; i < n; i++) cin >> S[i]; long long ans = 0; for(int i = 0; i < n; i++) { //i是起点 long l

2021-02-25 10:20:47 71

原创 uva725

#include<bits/stdc++.h>using namespace std;int main() { int n, kase = 0; string buf; while(scanf("%d", &n) == 1 && n) { int cnt = 0; if(kase++) printf("\n"); for(int fghij = 1234; ; fghij++) { //从1234开始枚举 int ab

2021-02-25 09:58:06 149

原创 字符串分割模板

这里以/分割字符串为例void split(string &s, vector<string>& path){ for(int i=0; i<s.size(); ++i) if(s[i]=='/') s[i] = ' '; stringstream ss(s); string buf; while(ss>>buf) path.push_back(buf);}

2021-02-24 16:40:28 170

原创 ccf日期计算

#include <bits/stdc++.h>using namespace std;//周日用数字0表示int monthdays[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; //平年时每个月有多少天int daysOfMonth(int y, int m) { //判断y年m月有几天 if ((y % 400 =

2021-02-24 10:25:51 130

原创 日期计算类问题模板

//周日用数字0表示int monthdays[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; //平年时每个月有多少天int daysOfMonth(int y, int m) { //判断y年m月有几天 if ((y % 400 == 0 || y % 4 == 0 && y % 100 != 0) &&amp

2021-02-24 10:09:43 109

原创 ccf节日

#include <bits/stdc++.h>using namespace std;//周日用数字0表示int monthdays[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; //平年时每个月有多少天int daysOfMonth(int y, int m) { //判断y年m月有几天 if ((y % 400 =

2021-02-24 10:08:04 102

原创 按出现频率的哈夫曼编码

#include <bits/stdc++.h>using namespace std;const int maxn = 10000 + 5;int lch[maxn], rch[maxn], feq[maxn];struct Node{ int no, f; Node(int nn, int ff): no(nn),f(ff) {} bool operator< (const Node& rhs) const { return f > rhs.f; }

2021-02-24 09:27:55 1526

原创 ccf碰撞的小球——碰撞前后相对位置不变

//思路:碰撞前后小球的相对位置不变。由于本题输入不是按位置顺序输入,因此用order[i]用于输入输出转换 #include <bits/stdc++.h> using namespace std;const int maxn = 100 + 5;struct Ant{ int id; //小球编号 int p; //小球位置 bool operator< (const Ant& a) const{ //按位置排序 return p < a.p;

2021-02-23 18:36:12 98

原创 ccf网络延时

#include <bits/stdc++.h> using namespace std;int n, m;const int maxn = 20000 + 5;struct Edge{ int from, to, dist; Edge(int u, int v, int d=1): from(u),to(v),dist(d) {}};vector<Edge> edges;vector<int> G[maxn];bool vis[maxn];int

2021-02-21 20:10:15 136

原创 ccf最优配餐

#include <bits/stdc++.h> using namespace std;const int INF = 1000000000;const int maxn = 1000 + 5;int n, m, k, _d;struct Cell{ int r, c; Cell(int r, int c):r(r),c(c) {}};const int dr[] = {-1,1,0,0};const int dc[] = {0,0,-1,1};int d[maxn][m

2021-02-21 19:09:25 100

原创 uva11624

#include<cstdio>#include<cstring>#include<queue>#include<algorithm>using namespace std;const int INF = 1000000000;const int maxr = 1000 + 5;const int maxc = 1000 + 5;int R, C;char maze[maxr][maxc];struct Cell { int r,

2021-02-21 17:58:20 117

原创 ccf游戏——BFS状态转换的应用

#include <bits/stdc++.h>using namespace std;int n, m, t;struct Node{ int r, c, t; Node(int r=0, int c=0, int t=0): r(r),c(c),t(t) {}};const int maxn = 100 + 5;int danger_area[maxn][maxn];bool vis[maxn][maxn][maxn];const int dr[] = {-1, 0, 1

2021-02-21 12:16:37 93

原创 ccf高速公路——Tarjan算法的应用

#include <bits/stdc++.h> using namespace std;const int maxn = 10000 + 5;vector<int> G[maxn];int pre[maxn], lowlink[maxn], sccno[maxn], dfs_clock, scc_cnt;stack<int> S;void dfs(int u){ pre[u] = lowlink[u] = ++dfs_clock; S.push(u);

2021-02-20 14:54:41 115

原创 ccf送货——打印无向图欧拉路的字典序路径

#include <bits/stdc++.h> using namespace std;const int maxn = 10000 + 5;set<int> G[maxn];bool vis[maxn][maxn];int pa[maxn];int findset(int x) {return pa[x]==x ? x : pa[x]=findset(pa[x]);}int deg[maxn];vector<int> d;struct Edge{

2021-02-20 11:19:46 131

原创 ccf最优灌溉——最小生成树的权值和

#include <bits/stdc++.h>using namespace std;const int maxn = 1000 + 5;const int INF = 1000000000;int n;int pa[maxn];int findset(int x) {return pa[x]==x ? x : pa[x]=findset(pa[x]);}struct Edge{ int u, v, d; Edge(int u, int v, int d):u(u),v(v)

2021-02-19 22:12:27 144

原创 ccf交通规划——迪杰斯特拉的应用

#include <bits/stdc++.h>using namespace std;const int maxn = 10000 + 10;const int INF = 1000000000;struct Edge{ int from, to, dist; Edge(int u, int v, int d): from(u),to(v),dist(d) {}};struct HeapNode{ int d, u; bool operator< (const Hea

2021-02-19 21:46:42 127

原创 ccf数据中心——最小生成树的最大边

#include <bits/stdc++.h>using namespace std;const int maxn = 100000 + 5;const int INF = 1000000000;int n;int pa[maxn];int findset(int x) {return pa[x]==x ? x : pa[x]=findset(pa[x]);}struct Edge{ int u, v, d; Edge(int u, int v, int d):u(u),v(

2021-02-19 14:23:06 110

原创 ccf地铁修建——最小生成树

#include <bits/stdc++.h>using namespace std;const int maxn = 100000 + 5;const int INF = 1000000000;int n;int pa[maxn];int findset(int x) {return pa[x]==x ? x : pa[x]=findset(pa[x]);}struct Edge{ int u, v, d; Edge(int u, int v, int d):u(u),v(

2021-02-19 14:00:20 159

原创 ccf24点——表达式树求解

#include <bits/stdc++.h> using namespace std;const int maxn = 1000;string str;int lch[maxn], rch[maxn]; char op[maxn];int nc = 0;int build_tree(const string& s, int x, int y){ int i, c1=-1, c2=-1, p=0; int u; if(y-x == 1){ u = ++nc;

2021-02-19 11:05:01 141

原创 ccf-csp 202012-1 期末预测之安全指数

#include <bits/stdc++.h> using namespace std;int main(){ int n; while(scanf("%d", &n)==1 && n){ int ans = 0, wi, si; while(n--){ scanf("%d%d", &wi, &si); ans += wi*si; } printf("%d\n", ans<0?0:ans); } return

2021-02-04 12:31:07 118

原创 uva1001

//将洞,起点和目标点都看作无向图中的结点,本题即求起点到目标点的最小距离 #include <bits/stdc++.h>using namespace std;const int MAXN = 100 + 5;const double eps = 1e-8;int dcmp(double x) { if(fabs(x) < eps) return 0; else return x < 0 ? -1 : 1; } //用于判断两个洞是否相交 double read_do

2021-02-04 10:49:42 86

原创 uva821

#include <bits/stdc++.h>#define _for(i,a,b) for( int i=(a); i<(b); ++i)#define _rep(i,a,b) for( int i=(a); i<=(b); ++i)using namespace std;const int MAXN = 100 + 5, INF = MAXN * MAXN;int d[MAXN][MAXN];int main(){ int n, a, b

2021-02-04 10:02:41 113

原创 uva10048

#include<cstdio>#include<algorithm>using namespace std;const int maxn = 100 + 5;const int INF = 1000000000;int d[maxn][maxn]; //两点间的最大噪声值的最小值:最大噪声值指的是可达路径上的最大噪声值,最小值是指多条可达路径最大噪声值的最小值 int main() { int n, m, Q, u, v, w, kase = 0; whi

2021-02-03 12:32:05 132

原创 uva247

//注意本题的电话圈是指最大的电话圈,即该电话中再加入任何一个其他人都不能相互可达 #include<cstdio>#include<vector>#include<string>#include<map>#include<cstring>using namespace std;vector<string> names;int ID(const string& s) { //返回s的编号,即下标 for

2021-02-03 11:35:35 103

原创 uva1395

#include<cstdio>#include<cmath>#include<cstring>#include<vector>#include<algorithm>using namespace std;const int maxn = 100 + 10;const int INF = 1000000000;int n;int pa[maxn];int findset(int x) { return pa[x] != x

2021-02-03 10:23:40 95

原创 uva439

#include <bits/stdc++.h>using namespace std;const int N = 8;struct Point{ int x, y; Point(int x=0, int y=0): x(x),y(y) {}};typedef Point Vector;Vector dirVs[N] = {{2,1}, {1,2}, {-1,2}, {-2,1}, {-2,-1}, {-1,-2}, {1,-2}, {2,-1}};Vector operato

2021-02-03 10:22:30 70

原创 uva10305

#include<cstdio>#include<cstring>const int maxn = 1000;int n, m, G[maxn][maxn], c[maxn], topo[maxn], t;//是否存在从u出发的拓扑序。如果有,将其存入topo中,返回true;否则返回false bool dfs(int u){ c[u] = -1; //访问u,并且未退出 for(int v = 0; v < n; v++) if(G[u][v

2021-02-03 10:21:57 108 1

原创 uva506

// 注意:显式安装的必须显式删除#include<iostream>#include<cstring>#include<string>#include<sstream>#include<vector>#include<algorithm>#include<map>using namespace std;const int maxn = 10000;int cnt = 0;map<string

2021-02-03 10:20:57 196 1

原创 uva1599

#include<cstdio>#include<cstring>#include<vector>#include<queue>using namespace std;const int maxn = 100000 + 5;const int INF = 1000000000; // maximal color//有向边 struct Edge { int u, v, c; //有向边的起点u,终点v和颜色c Edge(int

2021-02-02 21:48:36 102

原创 uva10129

#include<cstdio>#include<cstring>#include<vector>using namespace std;const int maxn = 1000 + 5;// 并查集(代码摘自《算法竞赛入门经典——训练指南》第三章)int pa[256];int findset(int x) { return pa[x] != x ? pa[x] = findset(pa[x]) : x; } //找到x的代表元 int used

2021-02-02 21:47:24 118

原创 uva11853

#include<cstdio>#include<cstdlib>#include<cmath>#include<cstring>#include<algorithm>using namespace std;const int maxn = 1000 + 5;const double W = 1000.0; //战场的宽度 int n, vis[maxn];double x[maxn], y[maxn], r[maxn], l

2021-02-02 21:46:34 130

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除