- 博客(18)
- 收藏
- 关注
原创 noip无穷大技巧
在这里插const int maxnum = 0x3f3f3f3f;0x3f3f3f3f的十进制是1061109567,是109级别的,而一般场合下的数据都是小于109的,所以它可以作为无穷大使用而不致出现数据大于无穷大的情形。一般dfs或者dp求最小值的问题中间会出现一些不存在的情况,我一般会采用一种方法就是返回一个很大的值,这样去最小的时候就不会取到这种情况了(不知道是不是专业做法),我一般在取这个“很大的值”的时候会选一个答案不可能的值,比如bfs求最短路一共是一个10000层的树,就取一个1
2022-03-26 17:29:55
212
原创 jdk练习
1、在界面上显示1~9共9个链接,能够在另一个页面中打印该数字的平方(用url传值)。<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%> <% for(int i=1;i<=10;i++){ %><%=i %>的平方是:<a href="url.jsp?number=<%=i %>">到达url show 界面</a><br&g
2021-09-24 20:56:53
2080
原创 二分搜索技术---随机生成n个元素,现要在这n个元素中找出一特定元素x
最初利用数组#include<iostream>#include<iomanip>#include<string>#include<algorithm>#include<ctime>using namespace std;int n,k,x; int main(){ cin>>n; while(n--){ cin>>k; cin>>x; int arr[k];
2021-09-24 16:05:24
586
原创 最大子列和问题
给定K个整数组成的序列{ N1, N2, …, NK},“连续子列”被定义为{ Ni, Ni+1, …,Nj},其中 1≤i≤j≤K。“最大子列和”则被定义为所有连续子列元素的和中最大者。例如给定序列{ -2, 11, -4, 13, -5, -2 },其连续子列{ 11, -4, 13 }有最大的和20。现要求你编写程序,计算给定整数序列的最大子列和。本题旨在测试各种不同的算法在各种数据情况下的表现。各组测试数据特点如下:,其中 1≤i≤j≤K。“最大子列和”则被定义为所有连续子列元素的和中
2021-05-16 15:27:16
156
原创 字母大小写转化函数
tolower是一种函数,功能是把字母字符转化为小写,非字母字符不作出处理。#include<iostream>using namespace std;int main(){string str="THIS IS A STRING.";for(int i=0;i<str.size();i++){ str[i]=tolower(str[i]);} cout<<str<<endl;return 0;}同样的,toupper是转为大写。...
2021-04-23 21:46:12
677
原创 String中find用法 拓展版(二)洛谷p1308
查找在字符串ss中,字符串s出现的次数一般我们都会想到用KMP字符串匹配算法,但是利用string中的find函数也是可以实现这个目的的string s,ss;ss.find(s,ans)s是子串,ans是下标,从那里开始找如果找到了返回下标,没找到返回一个很大的数,转为整形是int(-1) int ans=0; int count=0;//出现的次数 while((ans=ss.find(s,ans))<ss.length()){ ++count; ans++;
2021-04-13 20:30:02
297
原创 String中find用法 基础版(一)
有两个字符串 string s1, s2 ;在s1中找s2的位置;找到s2在s1中出现的位置由首次出现的s2的首字母的位置表示;find 函数 返回 s2 在s1中的首次下标位置,也就是第一个字符的首次位置返回一个名为 string::npos 的特殊值,说明查找没有匹配。string 类将 npos 定义为保证大于任何有效下标的值。int postions2=s1.find(s2);if(positions2==string::npso){cout<<s1<<
2021-04-11 15:08:10
959
原创 getline和gets和cin.getline
持续更新---记性不太好,总是将一些函数都很么的用法给忘记****两者均为字符串输入 gets适用于已知长度字符串,与getline函数功能相似,但是不能自定义结束符,只能换行符结束getline()接受的字符串长度不受限制,且第三个参数表示为字符串终止条件,默认为回车。#include<stack>#include<string>#include<iostream>using namespace std; int main(){ .
2021-04-11 14:11:13
1095
原创 Throwing cards away I(queue)
真的是忍不住吐槽一下这道坑点题!就是一道简单的队列题,但是我提交了四次,就是因为空格的位置Given is an ordered deck of n cards numbered 1 to n with card 1 at the top and card n at the bottom. The following operation is performed as long as there are at least two cards in the deck: Throw away the
2021-03-30 21:07:53
182
原创 Crossword solving
题目Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It’s well known that it is a very interesting occupation though it can be very difficult from time to time. In the cou
2021-03-29 21:06:10
204
原创 POJ 1426 Find The Multiple
题目:在2100年科学家发现了平行宇宙,但是新发现的Earth2的世界中所有数字都是由0和1组成的十进制数,如果从我们的世界穿越到Earth2,数字将发生一些变化,例如:一个正整数n,将被转化为n的一个非零的倍数m,这个m应当符合Earth2的数字规则。你可以假定n不大于200且m不多于100位。提示:本题采用Special Judge,你无需输出所有符合条件的m,你只需要输出任一符合条件的m即可。Input输入包含多组数据,每组数据仅一行,只包含一个正整数n,n==0时输入结束 (1 &.
2021-03-23 20:16:38
183
原创 POJ 3278 Catch That Cow
题目题目描述花花经过长时间的研究,终于研发出了能够跃迁的宇宙飞船。现在,他想要前往致远星。假设地球和致远星都在一个坐标轴上,其中地球位于坐标n,而致远星位于坐标k。而花花的飞船支持以下两种运动方式:1.飞行:在一个时间单位中,能够从坐标x移动到x-1或x+1;2.跃迁:在一个时间单位中,能够直接从x跃迁到2x。3.现在,花花想知道,他需要多长时间才能到达致远星?输入描述两个值,分别代表n和k。(0 ≤ n, k ≤ 100,000)输出描述输出花花最少需要的时间。样例输入5 17样例
2021-03-22 20:30:24
217
原创 poj 1321 棋盘问题
#include<iostream>#include<algorithm>#include<iomanip>#include<cmath>using namespace std;int n,k,sum=0; char a[10][10];int biaoji[10];//标记每一列 void dfs(int x,int kk){ if(kk==0){ sum+=1;//摆放的方案数目 return;//没有棋子了 } if
2021-03-19 21:40:24
131
原创 hdu1009 FatMouse‘ Trade
贪心老鼠要获得最多的食品,就要用最少的猫食换取最多的猫食,这就要求j[i]/f[i]的比例要大。比例越大,证明在这个房间,小鼠付出最少得到的收获最大。结构体排序#include<iostream>#include<algorithm>#include<iomanip>#include<cmath>using namespace std;int n,m;struct tr{ int j,f; double t;}...
2021-03-18 21:54:51
201
1
原创 hdu 1735 字数统计
学会了一种倒序巧妙的来设阻思路体现在代码中,注释为我所碰到的问题小垃圾一天啃一题#include<iostream>#include<algorithm>#include<iomanip>#include<cmath>using namespace std;int n,l,m,sum,sum1,sum0,m1; int a[10005][105];int len[10005];bool cmp(int x,int y){ return
2021-03-16 21:59:07
210
2
原创 poj 1700
#poj 1700#include<iostream>#include<algorithm>#include<iomanip>#include<cmath>using namespace std;int t,n;int a[1005];int sum;int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); while(cin>&g...
2021-03-15 20:05:26
290
2
原创 HDU-3999 The order of a Tree
#include<iostream>#include<algorithm>#include<iomanip>#include<cmath>#include<vector>using namespace std;vector<int> v; int n;struct node{ int data; node *lson; node *rson; node(){ lson=NULL; rson=NULL;.
2021-03-14 10:44:44
1207
5
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人