紫书题解
少年乖!
探究数理之美
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
uva1587 sort中cmp
①掌握结构体的运用 ②掌握c++库中sort函数第三个参数cmp的运用 #include<algorithm> #include<cstdio> using namespace std; struct rec { int x;int y; }widhe[6]; bool cmp(rec a,rec b) { if(a.x!=b.x) return a.x&原创 2018-12-10 17:15:46 · 307 阅读 · 3 评论 -
Uva 12171 离散化加BFS
对每一个长方体的坐标离散化处理 假想空气对空气bfs求联通 #include<bits/stdc++.h> using namespace std; const int maxn = 50 + 5; const int maxc = 1000 + 1; int n; int x0[maxn], y0[maxn], z0[maxn], x1[maxn], y1[maxn], z1[max...原创 2019-03-31 11:30:09 · 567 阅读 · 0 评论 -
Uva221 离散化
对于x而言无法对每个x枚举是否能看到建筑物 但是可以对每个相邻的x区间中枚举来判断是否能看到建筑物 #include <bits/stdc++.h> using namespace std; const int maxn = 100; struct Building{ int id; double x,y,w,d,h; // 左下角坐标、x方向宽、y方向宽、高度 ...原创 2019-03-30 15:04:54 · 237 阅读 · 0 评论 -
Uva10562(dfs递归看图写树
#include<bits/stdc++.h> using namespace std; const int maxn = 200+10; int n; char buf[maxn][maxn]; void dfs(int r,int c) { printf("%c(",buf[r][c]); if(r+1<n&&buf[r+1][c]=='|')...原创 2019-03-12 17:59:29 · 235 阅读 · 0 评论 -
HDU1116(有向图欧拉路判断
#include<bits/stdc++.h> using namespace std; int edege[26][26],out[26],in[26],tag[26]; void dfs(int u) { tag[u] = 1; for(int i =0;i<26;i++) { if(edege[u][i]&&tag[i...原创 2019-03-12 13:19:47 · 188 阅读 · 0 评论 -
Uva10305(有向图拓扑排序dfs
#include<bits/stdc++.h> using namespace std; const int maxn = 1000 + 5; int a[maxn][maxn];//保存两边之间的关系 int c[maxn]; int topo[maxn]; int n, m, t; bool dfs(int u){ c[u] = -1; for(int v=1; v...原创 2019-03-10 20:57:53 · 187 阅读 · 0 评论 -
Uva 816(bfs求最短路)
#include <bits/stdc++.h> using namespace std; struct Node{ int r,c,dir; Node(int r=0, int c=0, int dir=0):r(r),c(c),dir(dir) {} }; int have_edge[10][10][4][3];//当前状态 最后一维为是否可以沿着转弯的方向行走 i...原创 2019-03-09 23:21:09 · 254 阅读 · 0 评论 -
Uva 122 二叉树BFS
Trees are fundamental in many branches of computer science. Current state-of-the art parallel computers such as Thinking Machines' CM-5 are based on fat trees. Quad- and octal-trees are fundamental t...原创 2019-02-27 14:02:54 · 224 阅读 · 0 评论 -
uva 11988(链表题
You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problem with the keyboard is that sometimes the “home” key or the “end” key gets automatically pressed (intern...原创 2019-02-19 14:08:09 · 179 阅读 · 0 评论 -
Uva679 (完全二叉树
对于一个完全二叉树,节点k的左节点为2k,右节点为2k+1 对于第一个节点而言,编号I走过节点时,若I为奇数,则是向左走的第(I+1)/2个小球,当I为偶数时,是向右走的I/2个小球 对第二个节点也是如此 #include<cstdio> #include<cstring> int main() { int D,I; while(scanf("%d%d",&D,...原创 2019-02-23 00:40:16 · 319 阅读 · 0 评论 -
Uva 12657 (双向链表
最后要求输出奇数位数的和,记录操作4的次数和n的奇偶即可表示出答案 用双向链表来表示关系 #include<cstdio> #include<iostream> #include<algorithm> typedef long long ll; int righta[100005],lefta[100005]; void link(int L,int R) ...原创 2019-02-22 17:26:13 · 174 阅读 · 0 评论 -
uva1588
该题就是将读入的字符左右循环相加判断即可 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { char a[200],b[200];int i,j; while(scanf("%s %s",&a,&b)!=...原创 2018-12-12 15:55:42 · 620 阅读 · 0 评论 -
uva 10340
水题 一个一个往后查找即可 #include<stdio.h> #include<string.h> char s[1000000],t[1000000]; int main() { int i,j; while(scanf("%s %s",s,t)!=EOF) { int flag,k=-1; int a=strlen(s),b...原创 2018-12-10 17:13:28 · 127 阅读 · 0 评论 -
uva 202
这题有点难度 ,首先计算出小数点前面的数,并记录小数点后每一位的值以及得到该值的余数和出现该余数的位数,直到出现余数与前面相等或余数为0时终止并记下终止位数 #include<stdio.h> #include<string.h> int s[3003],r[3003],t[3003]; int main() { int a,b,i; while(~scan...原创 2018-12-10 17:11:48 · 509 阅读 · 2 评论 -
uva1368
按ACTG的顺序试出最小解即可 #include<stdio.h> #include<string.h> char a[50][1000]; int main() { int m,n,t,i,j; scanf("%d",&t); while(t--) { scanf("%d%d",&m,&n);getc...原创 2018-12-10 17:06:24 · 476 阅读 · 0 评论 -
uva232
模拟水题 Across时直接从左往右模拟 Down时记得要将上面以经用过的起始格抹去 #include<stdio.h> #include<string.h> char a[10][10];int b[10][10]; int main() { int c,r,i,j,k;int n=1; while(~scanf("%d",&r)&&...原创 2018-12-10 17:05:03 · 136 阅读 · 0 评论 -
UVA 227
典型模拟水题 注意条件判断 #include<stdio.h> int x,y; int main() { int i,j;char c,t; char a[5][5];int count=0; for(;;) { int flag=1; for(i=0;i<5;i++) { ...原创 2018-12-10 17:02:32 · 144 阅读 · 0 评论 -
uva455
简要思路:从周期为1递增往上试 #include<stdio.h> #include<string.h> int main() { int n;scanf("%d",&n); char a[82]; while(n--) { memset(a,0,sizeof(a)); int t,i,l,j;int flag=1...原创 2018-12-10 17:01:03 · 140 阅读 · 0 评论 -
uva 1225
水题 #include<stdio.h> #include<string.h> int main() { int a[10];int t,i,n;scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); scanf("%d",&n); for(i...原创 2018-12-10 16:59:08 · 196 阅读 · 0 评论 -
uva1586
水题 #include<stdio.h> #include<string.h> #include<ctype.h> int main() { int t,i;scanf("%d",&t); char a[82]; while(t--) { double sum=0; memset(a,'\0',size...原创 2018-12-10 16:58:07 · 172 阅读 · 0 评论 -
uva1585
水题不多说 #include&lt;stdio.h&gt; #include&lt;string.h&gt; int main() { int t,i;scanf("%d",&amp;t);char a[82]; getchar(); while(t--) { int d=0,s=0; memset(a,0,sizeof(a原创 2018-12-10 16:55:02 · 165 阅读 · 0 评论 -
uva11809 打表
这题其实就是将各种位数的最大浮点打表打出 然后根据AB来在表中找出对应的位数,由于位数过大可能会溢出,所以这里对最大浮点数进行了log的处理 N记录整数部分,M记录A所对应的值,也即小数部分 #include&lt;stdio.h&gt; #include&lt;math.h&gt; #include&lt;string.h&gt; int main() { int i,j; doub.原创 2018-12-12 16:02:08 · 361 阅读 · 0 评论
分享