自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 全排列STL

C++ STL全排列#include <iostream>#include <algorithm>using namespace std;int main (){ int arr[] = {2,1,0}; do { cout << arr[0] << ' ' << arr[1] << ' ' << arr[2]<<'\n'; } while ( p

2021-08-19 19:27:56 133

转载 POJ - 1797 Heavy Transportation(dijkstra最短路求最大边)

BackgroundHugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has build his giant steel crane to the place where

2020-08-19 21:31:45 159

原创 POJ 3159 candies

poj 3159candies差分约束+最短路/*给n个人派糖果,给出m组数据,每组数据包含A,B,c 三个数,意思是A的糖果数比B少的个数不多于c,即B的糖果数 - A的糖果数<= c 。最后求n 比 1 最多多多少糖果。【解题思路】这是一题典型的差分约束题。不妨将糖果数当作距离,把相差的最大糖果数看成有向边AB的权值,我们得到 dis[B]-dis[A]<=w(A,B)。看到这里,我们联想到求最短路时的松弛技术,即if(dis[B]>dis[A]+w(A,B), d

2020-08-19 21:07:33 169

原创 C,C++快速输入数据(快读)

inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return x * f;}x=read();

2020-05-22 22:56:28 620

原创 C语言r进制转换函数版

将十进制数转为R进制数void change(int r, int n) { int a[1005], x = 0; while (n) { a[x] = n % r; n /= r; x++; } for (int i = x - 1; i >= 0; i--)cout << a[i]; return;}将R进制数转为十进制数int To(int...

2019-11-27 17:21:45 665

原创 Codeforces Round #598 (Div. 3)D.Binary String Minimizing

传送门D. Binary String Minimizingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a binary string of length n (i. e. a string consi...

2019-11-05 19:00:00 146

原创 Codeforces Round #598 (Div. 3)B.Minimize the Permutation

传送门B. Minimize the Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation of length n. Recall that the permut...

2019-11-05 18:50:13 207

原创 判断素数

LL f(LL n) {if (n < 2)return 0;if (n == 2 || n == 3)return 1;if (n % 6 != 1 && n % 6 != 5)return 0;int t = sqrt(n);for (LL i = 5; i <= t; i += 6) {if (n%i == 0 || n % (i + 2) == 0)...

2019-10-08 22:55:05 255

原创 Codeforces Round #572 (Div. 2) C. Candies!

C. Candies!Consider a sequence of digits of length 2k [a1,a2,…,a2k]. We perform the following operation with it: replace pairs (a2i+1,a2i+2) with (a2i+1+a2i+2)mod10 for 0≤i<2k−1. For every i where...

2019-07-06 00:55:24 332

原创 二分查找函数

#include<iostream>#include<algorithm>#include<vector>#include<functional>using namespace std;int main(){ int a[]={4,10,11,30,30,69,70,96,100}; int a2[]={30,69,70}...

2019-06-11 18:36:05 357

原创 Codeforces Round #565 (Div. 3) C. Lose it!

You are given an array a consisting of n integers. Each ai is one of the six following numbers: 4,8,15,16,23,42.Your task is to remove the minimum number of elements to make this array good.An array...

2019-06-10 19:47:52 155

原创 Educational Codeforces Round 66 (Rated for Div. 2) B. Catch Overflow!

You are given a function f written in some basic language. The function accepts an integer value, which is immediately written into some variable x. x is an integer variable and can be assigned values...

2019-06-06 19:02:44 116

原创 Codeforces Global Round 3 B. Born This Way

Arkady bought an air ticket from a city A to a city C. Unfortunately, there are no direct flights, but there are a lot of flights from A to a city B, and from B to C.There are n flights from A to B, ...

2019-06-02 09:49:42 176

原创 2019吉林省acm竞赛 G.Spotlight

题意:判断一个点是否一条射线上思路:先判断这个点是否在这条直线上,然后在射线远处找到一个P点,如果P到这个点的距离小于等于P到起点的距离就在射线上#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<iostream>#incl...

2019-05-28 19:49:47 671

原创 Codeforces Round #561 (Div. 2) A. Silent Classroom

There are n students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct st...

2019-05-18 00:54:08 159

原创 Codeforces Round #561 (Div. 2) B. All the Vowels Please

Tom loves vowels, and he likes long words with many vowels. His favorite words are vowelly words. We say a word of length k is vowelly if there are positive integers n and m such that n⋅m=k and when t...

2019-05-18 00:33:25 146

原创 Codeforces Round #560 (Div. 3) C. Good String

Let’s call (yet again) a string good if its length is even, and every character in odd position of this string is different from the next character (the first character is different from the second, t...

2019-05-15 00:36:28 333

原创 Codeforces Round #559 (Div. 2) B. Expansion coefficient of the array

Let’s call an array of non-negative integers a1,a2,…,an a k-extension for some non-negative integer k if for all possible pairs of indices 1≤i,j≤n the inequality k⋅|i−j|≤min(ai,aj) is satisfied. The e...

2019-05-13 00:40:43 151

原创 Codeforces Round #557 (Div. 2) B. Double Matrix

You are given two n×mn×m matrices containing integers. A sequence of integers is strictly increasing if each next number is greater than the previous one. A row is strictly increasing if all numbers f...

2019-05-05 11:45:15 254

原创 Codeforces Round #557 (Div. 2) A. Zoning Restrictions Again

A. Zoning Restrictions Againtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are planning to build housing on a street. There are nn spots avail...

2019-05-05 01:35:19 350

原创 C++求最大公约数与最小公倍数的函数

递归int gcd(int a, int b){ return a % b ? gcd(b, a % b) : b;}int lcm(int a, int b){ return a * b / gcd(a, b);}

2019-05-04 23:15:13 7931 2

原创 dp洛谷1046 分组背包

金明今天很开心,家里购置的新房就要领钥匙了,新房里有一间金明自己专用的很宽敞的房间。更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过NN元钱就行”。今天一早,金明就开始做预算了,他把想买的物品分为两类:主件与附件,附件是从属于某个主件的,下表就是一些主件与附件的例子:主件 附件电脑 打印机,扫描仪书柜 图书书桌 台灯,文具工作椅 无如果要买归类为附件的物品...

2019-05-04 22:17:35 229 1

原创 Dividing 深搜与dp

Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same v...

2019-05-04 13:51:38 140

原创 DP背包问题-套

0-1背包Bessie has gone to the mall’s jewelry store and spies a charm bracelet. Of course, she’d like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i i...

2019-05-02 15:53:22 209

原创 大数四则运算

大数四则运算模板(java)import java.util.*;import java.math.*;public class Main { publicstatic void main(String[] args) { Scannercin=new Scanner(System.in); while(cin.hasNext()) ...

2019-04-17 19:21:17 231

原创 codeforces round #552(div 3) C.Gourmet Cat

C. Gourmet Cattime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has a cat and his cat is a real gourmet! Dependent on a day of the week he e...

2019-04-17 09:27:26 329

原创 差分数组--区间调度问题

适用于寻找很多区间中出现最多的那个元素。。。**#include <cstdio> int a[100011]; void init(int n) { for (int i = 1 ; i <= n ; i++) a[i] = 0; } int main() { int n; while (~sca...

2019-04-16 21:24:45 143

原创 栈与队列

栈stackC++ 栈stack的头文件为:#include c++ stl栈stack的成员函数介绍操作 比较和分配堆栈empty() 堆栈为空则返回真pop() 移除栈顶元素push() 在栈顶增加元素size() 返回栈中元素数目top() 返回栈顶元素队列queueC++队列Queue类成员函数如下:back()返回最后一个元素empty()如果队列空则返回真...

2019-04-10 18:53:40 123

原创 CodeForces - 1144E

You are given two strings ss and tt, both consisting of exactly kk lowercase Latin letters, ss is lexicographically less than tt.Let’s consider list of all strings consisting of exactly kk lowercase L...

2019-04-02 19:31:16 222

原创 codeforces round #550(div3) D

You are given an array aa consisting of nnintegers. You can perform the following operations arbitrary number of times (possibly, zero):Choose a pair of indices (i,j)(i,j) such that |i−j|=1|i−j|=1 (in...

2019-04-02 17:48:01 206

原创 codeforces #550 C

C. Two ShuffledTwo integer sequences existed initially — one of them was strictly increasing, and the other one — strictly decreasing.Strictly increasing sequence is a sequence of integers [x1<x2&...

2019-04-01 00:11:05 138

原创 codeforces #548 B. Chocolates

chocolatesB. Chocolatestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou went to the store, selling nn types of chocolates. There are aiai choc...

2019-03-22 22:41:21 168 1

空空如也

空空如也

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

TA关注的人

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