- 博客(32)
- 收藏
- 关注
原创 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
522
原创 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
199
原创 hdu1010(dfs+路径差奇偶剪枝
Problem DescriptionThe doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He rea...
2019-03-13 21:16:12
166
原创 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
204
原创 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
164
原创 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
157
原创 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
219
原创 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
182
原创 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
279
原创 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
142
原创 处女座的签到题(求第k大个数
链接:https://ac.nowcoder.com/acm/problem/21902来源:牛客网题目描述平面上有n个点,问:平面上所有三角形面积第k大的三角形的面积是多少?输入描述:第一行T,表示样例的个数。对于每一组样例,第一行两个整数n和k,接下来n行,每行两个整数x,y表示点的坐标T<=803<=n<=100-109<=x,y<=109...
2019-02-21 18:48:02
121
原创 cf Coffee and Coursework (Hard Version) 二分题
D2. Coffee and Coursework (Hard Version)time limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between easy and hard versi...
2019-02-20 15:15:16
278
原创 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
154
原创 数论概率 第三章 勾股数组与单位圆
1、单位圆上任意一个有理数点均可以表示为(1-m2 /1+m2 ,2m/1+m2)(除了(-1,0)其中m为任意有理数)2、PPT(u2 -v2,2uv,u2 +v2)(gcd(u,v)=1,u和v一奇一偶,u>v)3、每一个平方三角数均可以用x2-2y2 = 1的正整数解来表示...
2019-02-05 17:37:35
216
原创 数论概论 第二章 勾股数组
本原勾股数组(PPT):a2 +b2 =c2 (其中gcd(a,b,c)=1)1、 a,b一奇一偶 c为偶数2、 a,b,c可以表示为a=st b=(s2 -t2 )/2 c=(s2+t2)/2 其中s、t为奇数且gcd(s,t)=13、a,b中必有一个被3整除4、a,b,c中必有一个被5整除5、a为任意奇数 b为任意被4整出的偶数 c为被4除余1的素数6、若c可以写为c=p1p2...
2019-02-05 15:58:38
416
原创 数论概论 第一章 什么是数论
经典的数论问题:1、勾股数组2、an +bn =cn (n为正整数)3、素数无穷4、对于一个素数p≡1(mod4)则p可以表示为两个平方之和的形式5、平方数n2 三角数n*(n+1)/26、孪生素数:相邻奇数均为素数...
2019-02-03 20:02:41
1138
原创 hdu2546 经典01背包问题
Problem Description电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。Input多组数据。对...
2019-01-25 14:21:49
189
原创 cf杂题777c(单调数阵预处理
题意:给你一个n*m的数阵 对于一行到另一行,若存在一列从上到下递减,则称之符合题意The first line of the input contains two positive integers n and m (1 ≤ n·m ≤ 100 000) — the number of rows and the number of columns in the table respective...
2019-01-20 11:11:31
375
原创 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
320
原创 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
575
原创 uva1587 sort中cmp
①掌握结构体的运用②掌握c++库中sort函数第三个参数cmp的运用#include&amp;lt;algorithm&amp;gt;#include&amp;lt;cstdio&amp;gt;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
271
原创 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
104
原创 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
450
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
443
原创 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
114
原创 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
125
原创 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
110
原创 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
145
原创 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
146
原创 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
142
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人