自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 B. Two Arrays

传送门题目RedDreamer has an array a consisting of n non-negative integers, and an unlucky integer T.Let’s denote the misfortune of array b having length m as f(b) — the number of pairs of integers (i,j) such that 1≤i<j≤m and bi+bj=T. RedDreamer has to pai

2020-11-12 21:41:22 175

原创 Codeforces——B. Longest Palindrome

Codeforces——B. Longest Palindrome传送门Returning back to problem solving, Gildong is now studying about palindromes. He learned that a palindrome is a string that is the same as its reverse. For example, strings “pop”, “noon”, “x”, and “kkkkkk” are palindro

2020-11-11 21:06:42 143

原创 codeforces Round #678 (Div. 2) 1436

A. Reorder题解就是求数组a里面元素的和 判断是否与 k 相等#include<iostream>#include<algorithm>using namespace std;const int N = 1e6 + 10;int t, n, k, a;int main () { cin >> t; while(t -- ) { int res = 0; cin >> n >> k; for(int

2020-11-01 21:14:47 119

原创 Codeforce 1420.B

传送门题目Danik urgently needs rock and lever! Obviously, the easiest way to get these things is to ask Hermit Lizard for them.Hermit Lizard agreed to give Danik the lever. But to get a stone, Danik needs to solve the following task.You are given a positive

2020-09-27 16:53:22 141

原创 Acwing 788 逆序对的数量归并排序

传送门文章目录题目大意输入格式输出格式数据范围输入样例:输出样例:题解题目大意给定一个长度为n的整数数列,请你计算数列中的逆序对的数量。逆序对的定义如下:对于数列的第 i 个和第 j 个元素,如果满足 i < j 且 a[i] > a[j],则其为一个逆序对;否则不是。输入格式第一行包含整数n,表示数列的长度。第二行包含 n 个整数,表示整个数列。输出格式输出一个整数,表示逆序对的个数。数据范围1≤n≤100000输入样例:62 3 4 5 6 1输出样例:5

2020-09-19 18:55:17 137

原创 浮点数的二分 Acwing790 数的三次方根

浮点数的二分传送门题目大意给定一个浮点数n,求它的三次方根。输入格式共一行,包含一个浮点数n。输出格式共一行,包含一个浮点数,表示问题的解。注意,结果保留6位小数。数据范围−10000≤n≤10000−10000≤n≤10000输入样例:1000.00输出样例:10.000000注意: 题目要求保留小数点后6位题解#include <iostream>using namespace std;const int esp = 1e-8;double n;

2020-09-19 11:05:48 102

原创 快速排序 快速选择排序 Acwing 786第k个数

s://www.acwing.com/problem/content/788/)题目大意基本上就是裸体给定一个长度为n的整数数列,以及一个整数k,用快速选择算法求出数列的第k小的数是多少。输入格式第一行包含两个整数 n 和 k。第二行包含 n 个整数(所有整数均在1~109109范围内),表示整数数列。输出格式输出一个整数,表示数列的第k小数。数据范围1≤n≤1000001≤n≤100000,1≤k≤n输入样例:5 32 4 1 5 3输出样例:3注意 在递归的时候一定要

2020-09-19 10:28:38 222

原创 整数二分 Acwing 789数的范围

整数二分 注意边界问题为了避免死循环传送门l = mid 时 mid = l + r + 1 >> 1; //因为在c/c++ 里面是向下取整同理r = mid 时 mid = l + r >> 1;下面直接给出了本题的题解#include<iostream>using namespace std;const int N = 1e5 + 10;int n, q, k, a[N];int main (){ scanf("%d %d

2020-09-19 09:38:32 157

原创 快速排序 Acwing 785快速排序

快速排序 nlogn模板题#include <iostream>using namespace std;const int N = 1e5 + 10;int n;int a[N];void quick_sort(int q[], int l, int r){ if(l >= r) return ; int x = q[(l + r) / 2], i = l - 1, j = r + 1; while(i < j) {

2020-09-18 14:07:22 102

原创 归并排序 Acwing 787

归并排序 nlongn运用分治的思想 递归#include<iostream>using namespace std;const int N = 1e5 + 10;int n;int a[N], temp[N];void merge_sort(int q[],int l,int r){ if(l >= r) return ; int mid = l + r >> 1; merge_sort(q, l, mid); mer

2020-09-18 14:01:11 136

原创 POJ 3974 Palindrome manacher 马拉车

传送门manacher算法:定义数组p[i]表示以i为中心的(包含i这个字符)回文串半径长id 表示回文子串的中心位置mx 表示回文子串的最右边的位置假设原字符串为”abcba“, 然后构造一个新的字符串“@#a#b#c#b#a#" (解决奇数偶数造成的分类)题解#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algor

2020-07-13 16:41:19 106

原创 greater和less的用法

greater使内置函数从大到小排序,而less使的内置函数从小到大排序。注意:sort 用greater排序,是a[0]到a[n]从大到小排序priority_queue用greater排序,是先出最小值#include#include<bits/stdc++.h>#includeusing namespace std;int main (){int a[10]={...

2019-11-14 13:32:49 1205 2

原创 二分法 Pie HDU - 1969

#include< cstdio>#include< cmath>#include< iostream>#include< algorithm>using namespace std;#define eps 1e-7const double PI=acos(-1.0); //精确计算π的值,减小误差int n,f;double ca...

2019-11-13 16:49:10 131

原创 字符串逆转

下面介绍了两种字符串逆转的方法#include < iostream >#include<bits/stdc++.h>#include< algorithm>#include< string>using namespace std;#define N 20#define M 30int main (){int len;char...

2019-11-11 20:47:35 95

原创 逆转函数 的使用

逆转函数reverse的使用#include iostream#include<bits/stdc++.h>#include algorithmusing namespace std;int main (){int a[5]={1,2,3,4,5};float b[5]={1.1,2.2,3.3,4.4,5.5};reverse (a,a+5);reverse a...

2019-11-11 20:31:18 195

原创 sort排序

#include#includeusing namespace std;bool cmp(int a,int b){ return a>b;}int main (){ int a[10]={56,23,1,2,4,3,5,7,8,65}; sort(a,a+10); int i; for(i=0;i<10;i++...

2019-11-10 10:27:51 82

空空如也

空空如也

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

TA关注的人

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