刷题
每天都要吃饱饱
绝境当搏命 前途无量
展开
-
二分搜索技术---随机生成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 · 457 阅读 · 0 评论 -
最大子列和问题
给定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 · 118 阅读 · 0 评论 -
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 · 116 阅读 · 0 评论 -
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 · 147 阅读 · 0 评论 -
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 · 127 阅读 · 0 评论 -
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 · 144 阅读 · 0 评论 -
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 · 1140 阅读 · 5 评论 -
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 · 92 阅读 · 0 评论 -
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 · 137 阅读 · 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 · 154 阅读 · 2 评论