自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 B - Sum of Consecutive Prime Numbers

Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive integer have? For example, the integer 53 has two representations 5 + 7 + 11 + 13 + 17 and 53. The integer 41 h

2021-05-05 20:31:05 210

原创 L1-070 吃火锅 (15 分)c++中,字符串查找子字符串的用法

题目链接以上图片来自微信朋友圈:这种天气你有什么破事打电话给我基本没用。但是如果你说“吃火锅”,那就厉害了,我们的故事就开始了。本题要求你实现一个程序,自动检查你朋友给你发来的信息里有没有 chi1 huo3 guo1。输入格式:输入每行给出一句不超过 80 个字符的、以回车结尾的朋友信息,信息为非空字符串,仅包括字母、数字、空格、可见的半角标点符号。当读到某一行只有一个英文句点 . 时,输入结束,此行不算在朋友信息里。输出格式:首先在一行中输出朋友信息的总条数。然后对朋友的每一行信息,检查其

2021-04-21 19:05:59 298

原创 HDU1047.Integer Inquiry

HDU1047.Integer Inquiry(大数求和)One of the first users of BIT’s new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers.This supercomputer is great,’’ remarked Ch

2021-04-11 18:58:48 190

原创 E - How Many Fibs?

Recall the definition of the Fibonacci numbers:f1 := 1f2 := 2fn := fn-1 + fn-2 (n >= 3)Given two numbers a and b, calculate how many Fibonacci numbers are in the range [a, b].InputThe input contains several test cases. Each test case consists of t

2021-04-11 09:36:59 147

原创 D - Hat‘s Fibonacci

A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1.F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4)Your task is to take a number as input, and

2021-04-09 21:07:36 92

原创 B - 大明A+B

话说,经过了漫长的一个多月,小明已经成长了许多,所以他改了一个名字叫“大明”。这时他已经不是那个只会做100以内加法的那个“小明”了,现在他甚至会任意长度的正小数的加法。现在,给你两个正的小数A和B,你的任务是代表大明计算出A+B的值。Input本题目包含多组测试数据,请处理到文件结束。每一组测试数据在一行里面包含两个长度不大于400的正小数A和B。Output请在一行里面输出输出A+B的值,请输出最简形式。详细要求请见Sample Output。Sample Input1.1 2.91

2021-04-05 17:23:53 96

原创 H - Strange fuction

Now, here is a fuction:F(x) = 6 * x7+8*x6+7x3+5*x2-yx (0 <= x <=100)Can you find the minimum value when x is between 0 and 100.InputThe first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T li

2021-03-27 11:24:47 60

原创 E - Can you solve this equation?

Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solution between 0 and 100;Now please try your lucky.InputThe first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines foll

2021-03-27 10:33:55 128

原创 J - 查找最接近的元素

在一个非降序列中,查找与给定值最接近的元素。Input第一行包含一个整数n,为非降序列长度。1 <= n <= 100000。第二行包含n个整数,为非降序列各元素。所有元素的大小均在0-1,000,000,000之间。第三行包含一个整数m,为要询问的给定值个数。1 <= m <= 10000。接下来m行,每行一个整数,为要询问最接近元素的给定值。所有给定值的大小均在0-1,000,000,000之间。Outputm行,每行一个整数,为最接近相应给定值的元素值,保持输入顺

2021-03-26 20:11:40 113

原创 B - Rightmost Digit

Given a positive integer N, you should output the most right digit of N^N.InputThe input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.Each test case contains a sing

2021-03-25 20:36:21 72

原创 UVA10382 Watering Grass

戳一戳在I米长w米宽的水平草坪上安装了n个洒水器。每个洒水喷头都安装在长条的水平中心线上。对于每个洒水车,我们都知道它的位置,即从中心线左端到它的距离和它的工作半径。为了给整个草坪浇水,最少需要打开多少个洒水器?...

2021-03-22 21:05:00 170

原创 M - Physical Examination

WANGPENG is a freshman. He is requested to have a physical examination when entering the university.Now WANGPENG arrives at the hospital. Er…… There are so many students, and the number is increasing!There are many examination subjects to do, and there i

2021-03-21 20:18:24 118

原创 B - Best Cow Line

FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them past the judges.The contest organizers adopted a new registration scheme this year: simpl

2021-03-20 11:28:57 112

原创 C - FatMouse‘ Trade{性价比问题}

FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food. FatMouse do

2021-03-18 18:42:04 140

原创 H - 字数统计

一天,淘气的Tom不小心将水泼到了他哥哥Jerry刚完成的作文上。原本崭新的作文纸顿时变得皱巴巴的,更糟糕的是由于水的关系,许多字都看不清了。可怜的Tom知道他闯下大祸了,等Jerry回来一定少不了一顿修理。现在Tom只想知道Jerry的作文被“破坏”了多少。  Jerry用方格纸来写作文,每行有L个格子。(图1显示的是L = 10时的一篇作文,’X’表示该格有字,该文有三个段落)。图1图2图2显示的是浸水后的作文 ,‘O’表示这个位置上的文字已经被破坏。可是Tom并不知道原先哪些格子有文字,哪

2021-03-17 20:29:14 152

原创 P4995 跳跳!

戳一戳题解:简单贪心要注意的地方是体力要用long long 型定义代码:#include <iostream>#include <algorithm>using namespace std;int a[305];bool myCompare(int aa, int bb) { return aa > bb;}int main() { int n; cin >> n; for (int i = 0; i < n; i++)

2021-03-15 20:15:57 137

原创 L1-025 正整数A+B (15 分)

戳一戳感受:本人菜鸟一个写了那么长代码,却不知道用几个变量标记结果还wa了两个(找半天还是不知道哪里卡住了,等我知道了后续更新)还有测试数据不知道到怎么卡点的如果是单纯的四位数,但是范围超过1000的情况怎么办题解:感觉没啥好解释的最多注意一下A和B都在区间[1,1000]上ac代码:转自他人博客点一点,找到代码源#include <iostream>#include <string>using namespace std;string a, b;i

2021-03-15 19:42:42 70

原创 2021-03-14

戳一戳https://www.luogu.com.cn/problem/P2240题解:别把这题想复杂化就行简单贪心但可能会被卡数据出现不管怎么改(虽然确实可能是对的)但结果总是有一个会wa代码中有详细注释代码:#include <iostream>#include <cstdio>#include <algorithm>using namespace std;struct node {//定义结构体 double w;//重量

2021-03-14 20:26:54 102

原创 P1803 凌乱的yyy / 线段覆盖

戳一戳题解:根据比赛结束时间对比赛进行排序简单的贪心思想代码:#include <iostream>#include <vector>#include <algorithm>using namespace std;typedef struct { int start; int end;}st;st stu[1000005];bool myCompare(st a, st b) { if (a.end == b.end) { ret

2021-03-14 19:13:13 128

原创 P1090 [NOIP2004 提高组] 合并果子 / [USACO06NOV] Fence Repair G

传送门思想:贪心最优解是先将a,b进行合并,得到(a+b),耗费的体力为(a+b)将(a+b)和c,d进行比较,将较小的两个数字合并(假设是c,d)得到(c+d),耗费的体力为(c+d),然后将(a+b)和(c+d)进行合并得到(a+b+c+d)耗费的总体力为(a+b+c+d+a+b+c+d)。代码:...

2021-03-14 18:47:28 141

原创 P1106 删数问题 {详细题解}

戳一戳题解:对于这题我们使用贪心思想贪心策略是比较前一个数是不是比后面一位数要大(因为要得到最小的数,就要尽量让数的前面位数小)如果要大的话,就把当前的数给删去得到一个新的string然后再重新进行一次两两大小的判断每重新判断一次就会删去一个数也就是总体要判断k次当然也会出现没有前面的数比后面的数要大的情况此时这个string里面的数是呈现递增的现象的,那么就删除最后一个元素另外:要考虑三种特殊情况:一种是:前导0要删去 列如:012一种是:数中间的零不能删去 列如:10

2021-03-14 10:40:42 502

原创 P5019 [NOIP2018 提高组] 铺设道路

戳一戳题解:要想利用最少的天数将这些坑填完整体最优解找局部最优解对于第一到第二个坑最少用四天即可填完对于第二到第三个坑由于坑要比前面的坑要浅那么先不要考虑填完到水平线的天数因为前面的四天可以顺便将这个坑给填到水平线的高度对于第三个坑和第四个坑比,要想得到最优的天数来填完这个坑那么只需要把这个坑来填到和上一个坑水平及以上即可,因为剩余的坑位可以搭第一次四天的顺风车现在来到第四个坑和第五个坑,还是和前面一样不考虑,因为比前面浅,可以搭前面补坑的天数的顺风车第五个坑和第六个坑来比较,及让

2021-03-13 21:02:27 206

原创 P1094 [NOIP2007 普及组] 纪念品分组

戳一戳题解:先从小到大排个序然后最小与最大两两组合讨论与w的关系满足小于等于w,则两个纪念品组成一队否则,更大的那个纪念品自己打包成一队代码:#include <iostream>#include <algorithm>#include <vector>using namespace std;int main() { int w; int n; cin >> w >> n; vector<int> pr

2021-03-13 19:25:16 103

原创 痞老板玩扫雷【oj】

DescriptionInputOutput以下是我的超时代码:#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <string>#include <cmath>#include <algorithm>#include <queue>#include <map>

2021-02-12 11:07:12 189 1

原创 你听说过史莱姆吗??【oj】

DescriptionInputOutputinpu 5output 1input 8output 0分析:如果只有小Q一个人的话,就会有1,2,4,8,16,32,,,等情况,是以二的指数增长然后用小Q想要对的军队数对小Q一个人可能繁衍的数遍历除,以找到最优的情况,及小Q占了大多数军队数,而剩余的军队数量单凭小Q无法实现,此时就需要邀请另一位史莱姆来帮他实现了,当然也终究会到请来的史莱姆也解决不了的时候,这时候就需要再请一位。。。以此类推,直到解决为

2021-02-09 20:19:41 121

原创 cells‘problem【oj】

DescriptionInputOutputinput1673 4 5 2 9 1 149 2 7 1118 4 3 1 2 7 8 7 9 4 2142211 781 1 1 1 1 1 1 1output13 1 4 1 5 9 29 1 2 78 2 4 4 3 9 1 7 2 8 74211 71 1 1 1 1 1 1 1input2141453324 2 1453324 1output21453324 1 2 1453324分析

2021-02-09 20:05:04 64

原创 阿牛的EOF牛肉串

Problem Description今年的ACM暑期集训队一共有18人,分为6支队伍。其中有一个叫做EOF的队伍,由04级的阿牛、XC以及05级的COY组成。在共同的集训生活中,大家建立了深厚的友谊,阿牛准备做点什么来纪念这段激情燃烧的岁月,想了一想,阿牛从家里拿来了一块上等的牛肉干,准备在上面刻下一个长度为n的只由"E" “O” "F"三种字符组成的字符串(可以只有其中一种或两种字符,但绝对不能有其他字符),阿牛同时禁止在串中出现O相邻的情况,他认为,"OO"看起来就像发怒的眼睛,效果不好。你,NE

2021-02-08 16:06:49 207

原创 一只小蜜蜂...

一只小蜜蜂:有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。其中,蜂房的结构如下所示。这题很容易想到递归的做法想到达4必需到达3或2,然后计算到达3或2的所有路线,加起来就是所有的路线数,得到递推公式 f(4)=f(3)+f(2);,递归中当执行到20的长度便会很大,我们就不适用int类型,使用long long的输入,与%lld的输出递归的时间复杂度:O(nlgn)第一种很常见的递归想法很容易出现TLE下面是TLE的代码,提供参

2021-02-08 15:11:40 220

原创 超级楼梯

有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?思路:对于M级楼梯,我现在站在第一级楼梯上,还剩M-1级楼梯要等着我去爬完,让step=M-1表示要爬的级数,我的腿很短,每次要么爬一级,要么爬两级考虑两种极端情况一种是一级一级向上蹦的情况一种是两级两级向上跨的情况两级两级向上跨的那种情况还要考虑最后有没有留出1个单独台阶所以step要分奇数偶数来讨论用组合数公式发现(以出现几个2来组合)出现0个2,1个2,2个2…等等…等等不管是奇数还是偶数,

2021-02-08 11:54:36 637 1

原创 Kalevitch and Chess[codeforces]分析

InputWWWBWWBWB B B B B B B BWWWBWWBWWWWBWWBWWWWBWWBWWWWBWWBWWWWBWWBWWWWBWWBWOutput3InputWWWWWWWWB B B B B B B BWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWOutput1我为大家提供一种思路:题目要求求出the minimum amount of rows and columns that Kalevi

2021-02-03 15:30:51 110

原创 Keyboard ,CodeForces - 474A【分析】

InputRs;;upimrrfod;pbrOutputallyouneedislove此题数据很少,是可以直接暴力枚举的。首先要定义个数组来存放所有可能按到的键每判断一个字符都可以直接输出来一个字符,如果不直接输出,选择赋值后再来整体输出,显得多此一举,不仅如此,还有可能出现一些让自己头皮发麻的问题,比如看我文章的最后一个代码如果你认为按到的键不可能只有30个键,那么你可以看我写的第二个代码(两个代码结果都是对的)#include <iostream>#include &l

2021-02-02 23:10:19 143

原创 Erase-Remove惯用法

使用erase()删除是基于元素的位置信息决定的,但是在实际应用场景中,根据元素的值来删除会显得更加直观。#include <iostream>#include <vector>#include <algorithm>using namespace std;void print(const vector<int>&vec){ for(unsigned i=0; i<vec.size(); i++) {

2021-01-28 15:52:44 452

原创 Strange List

Strange ListYou have given an array a of length n and an integer x to a brand new robot. What the robot does is the following: it iterates over the elements of the array, let the current element be q. If q is divisible by x, the robot adds x copies of the

2021-01-27 17:33:44 142

原创 Vector-Erase[stl练习]

Vector-EraseYou are provided with a vector of integers. Then, you are given queries. For the first query, you are provided with integer, which denotes a position in the vector. The value at this position in the vector needs to be erased. The next query co

2021-01-27 16:04:01 365

原创 Red and Blue

Red and BlueMonocarp had a sequence a consisting of n+m integers a1,a2,…,an+m. He painted the elements into two colors, red and blue; n elements were painted red, all other m elements were painted blue.After painting the elements, he has written two sequ

2021-01-26 22:03:26 233

原创 Vector-Sort[练习]

Vector-SortYou are given N integers.Sort the N integers and print the sorted order.Store the N integers in a vector.Vectors are sequence containers representing arrays that can change in size.Declaration:vectorv; (creates an empty vector of integers)S

2021-01-26 20:00:52 477

原创 Fence

FenceThere is a fence in front of Polycarpus’s home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights.Fence for n = 7 and

2021-01-25 22:22:40 343 1

原创 环状序列(UVa1584)

长度为n的环状串有n种表示法,分别为某个位置开始顺时针得到。CGAGTCAGCT,GAGTCAGCTC,AGTCAGCTCG等。在这些表示法中,字典序最小的称为“最小表示”。输入一个长度为n(n<=100)的环状DNA串(只包含A、C、G、T这4种字符)的一种表示法,你的任务是输出该环状串的最小表示。例如,CTCC的最小表示是CCCT,CGAGTCAGCT的最小表示为AGCTCGAGTC。样例输入:2CGAGTCAGCTCTCC样例输出:AGCTCGAGTCCCCT描述了很多,其实就是

2021-01-23 18:40:59 333 1

原创 求平均成绩

求平均成绩假设一个班有n(n<=50)个学生,每人考m(m<=5)门课,求每个学生的平均成绩和每门课的平均成绩,并输出各科成绩均大于等于平均成绩的学生数量。第一次写出了一点小bug哈哈哈哈哈#include <stdio.h>#include <stdlib.h>#include <math.h>#define maxn 111#include <string.h>int score[maxn][maxn];double std

2021-01-20 22:52:09 496

原创 Fair Division

Fair DivisionAlice and Bob received n candies from their parents. Each candy weighs either 1 gram or 2 grams. Now they want to divide all candies among themselves fairly so that the total weight of Alice’s candies is equal to the total weight of Bob’s can

2021-01-20 22:20:31 214

空空如也

空空如也

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

TA关注的人

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