- 博客(243)
- 收藏
- 关注
原创 Python入门
输出输出:print("12345")输出变量:s=123print(s)输入n = input()分支语句if 判断条件: 成立语句elif 判断条件: 成立语句else: 成立语句if 3 > 5: print("3 > 5")elif 3 == 5: print("3 = 5")else" print("3 < 5")a = 5a = (3 if 3 < 5 else 7)此时a = 3a = (3 if 3 >
2020-06-10 20:06:07
250
原创 素数筛模板
//素数筛,集合为1是素数const ll primeSieveMax = 100005;ll primeSet[primeSieveMax] = { 0 };void primeSieve() { f(i, 2, primeSieveMax) { primeSet[i] = 1; } f(i, 2, primeSieveMax) { if (primeSet[i] == 1) { for (ll j = i * 2; j <= primeSieveMax; j += i)
2020-05-18 21:19:01
175
原创 Educational Codeforces Round 86 (Rated for Div. 2)C. Yet Another Counting Problem
题目地址:https://codeforces.com/contest/1342/problem/C题意: 输入两个整数a,b且(1 <= a, b <= 200)和一个查询次数q且(1 <= q <= 500)。 每次查询输入一个区间l,r且(1 <= l <= r <= 1e18) 问在这个区间内的数字有多少数字i满足(i % a) % b !...
2020-04-27 18:49:47
172
原创 Codeforces Round #616 (Div. 2)B. Array Sharpening
题目地址:https://codeforces.com/contest/1291/problem/B题意: 输入n,接着输入n个数字,这n个数字构成一个数组。 你可以对数组中任意一个数字进行任意次数的-1操作。 问:这个数组能不能变成一个锐化的数组。数组锐化:三种形式 1.递增:{0,1,2,3,4} 2.递减:{4,3,2,1,0} 3.只有一个坡度:{0,1,2,3,4,3,2...
2020-04-17 11:44:43
132
原创 Educational Codeforces Round 81 (Rated for Div. 2)B. Infinite Prefixes(思维、公式推导)
题目地址:https://codeforces.com/contest/1295/problem/B参考大佬的地址:https://www.cnblogs.com/pixel-Teee/p/12247178.html题意: 每组输入一个n和m,n代表字符串s的长度,m的意思是0比1的数量多m个 你有一个字符串s,字符串s是一个01串,字符串t是由无限个字符串s相连,例如s="01001"那...
2020-04-16 18:40:55
129
原创 Codeforces Round #615 (Div. 3)D. MEX maximizing(思维)
题目地址:https://codeforces.com/contest/1294/problem/D题意: 你有一个空白数组,需要向里面插入n个数字,这些数字可以加k或减k任意次。 问每次加入后数组内的没有出现的最小的非负整数是多少例如: n = 7, k = 3 0 1 2 2 0 0 10 第一次插入0,此时没有出现的最小的非负整数是1;数组{0} 第二次插入1,此...
2020-04-15 22:27:24
140
原创 Educational Codeforces Round 80 (Rated for Div. 2)B. Yet Another Meme Problem(数论)(公式推导)
题目地址:https://codeforces.com/contest/1288/problem/B大佬地址:https://www.cnblogs.com/yanying7/p/12357953.html公式推导,数论强者恐怖如斯啊#include<cstdio>#include<cstring>#include<cstdlib>#include&...
2020-04-14 22:49:25
123
原创 Educational Codeforces Round 80 (Rated for Div. 2)A. Deadline(暴力枚举或数论)(公式推导)
题目地址:https://codeforces.com/contest/1288/problem/A大佬的地址:题意在这里,大佬恐怖如斯,膜拜#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#include<string>#include<...
2020-04-14 22:16:43
107
原创 Codeforces Round #612 (Div. 2) B. Hyperset(枚举+map)
题目地址:https://codeforces.com/contest/1287/problem/Bn行字符串,每个字符串k个字符,每个字符串只能是’S’、‘T’、'E’这三个字符,三个字符串算一组,问有多少组。3 3SETETSTSE//第一列SET都不一样,第二列ETS都不一样,第三列TSE都不一样//所以这三个字符串算1组3 4SETEETSETSES//第一列SE...
2020-04-14 19:57:40
157
原创 POJ - 3468 A Simple Problem with Integers(线段树模板题)
题目地址http://poj.org/problem?id=3468题面:You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given i...
2020-03-05 19:04:12
156
原创 POJ3264 Balanced Lineup(线段树模板题)
题目地址题意For the daily milking, Farmer John’s N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep...
2020-03-05 11:04:24
252
2
原创 P1865 A % B Problem
题目背景题目名称是吸引你点进来的实际上该题还是很水的题目描述区间质数个数输入格式一行两个整数 询问次数n,范围m接下来n行,每行两个整数 l,r 表示区间输出格式对于每次询问输出个数 t,如l或r∉[1,m]输出 Crossing the line输入输出样例输入 #1复制2 51 32 6输出 #1复制2Crossing the line说明/提示【数据范围...
2019-12-28 09:37:01
165
原创 洛谷P1014 Cantor表
题目描述现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的。他是用下面这一张表来证明这一命题的:1/11/1 , 1/21/2 , 1/31/3 , 1/41/4, 1/51/5, …2/12/1, 2/22/2 , 2/32/3, 2/42/4, …3/13/1 , 3/23/2, 3/33/3, …4/14/1, 4/24/2, …5/15/1, …… 我们以...
2019-10-01 02:36:57
147
原创 P1036 选数(简单dfs递归)
题目地址题目描述已知 nn 个整数 x_1,x_2,…,x_nx1 ,x2 ,…,xn ,以及11个整数kk(k<nk<n)。从nn个整数中任选kk个整数相加,可分别得到一系列的和。例如当n=4,k=3n=4,k=3,44个整数分别为3,7,12,193,7,12,19时,可得全部的组合与它们的和为:3+7+12=223+7+12=223+7+19=29...
2019-08-04 18:32:51
276
原创 007:滑雪(百练/POJ1088)(DFS+DP)
总时间限制: 1000ms 内存限制: 65536kB描述Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长的滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子1 2 3 4 516 17 18 19 615 24 25...
2019-07-22 21:58:07
135
原创 006:Charm Bracelet(裸01背包)
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 iin the sup...
2019-07-22 21:51:14
208
原创 005:求排列的逆序数
总时间限制: 1000ms 内存限制: 65536kB描述在Internet上的搜索引擎经常需要对信息进行比较,比如可以通过某个人对一些事物的排名来估计他(或她)对各种不同信息的兴趣,从而实现个性化的服务。对于不同的排名结果可以用逆序来评价它们之间的差异。考虑1,2,…,n的排列i1,i2,…,in,如果其中存在j,k,满足 j < k 且 ij > ik, 那么就称(ij,ik...
2019-07-16 22:46:27
282
原创 004:输出前k大的数
总时间限制: 10000ms 单个测试点时间限制: 1000ms 内存限制: 65536kB描述给定一个数组,统计前k大的数并且把这k个数从大到小输出。输入第一行包含一个整数n,表示数组的大小。n < 100000。第二行包含n个整数,表示数组的元素,整数之间以一个空格分开。每个整数的绝对值不超过100000000。第三行包含一个整数k。k < n。输出从大到小输出前k...
2019-07-16 22:37:13
140
原创 003:月度开销(二分搜索)
总时间限制: 1000ms 内存限制: 65536kB描述农夫约翰是一个精明的会计师。他意识到自己可能没有足够的钱来维持农场的运转了。他计算出并记录下了接下来 N (1 ≤ N ≤ 100,000) 天里每天需要的开销。约翰打算为连续的M (1 ≤ M ≤ N) 个财政周期创建预算案,他把一个财政周期命名为fajo月。每个fajo月包含一天或连续的多天,每天被恰好包含在一个fajo月里。约...
2019-07-16 11:21:01
327
原创 002:派(二分搜索)
总时间限制: 1000ms 内存限制: 65536kB描述我的生日要到了!根据习俗,我需要将一些派分给大家。我有N个不同口味、不同大小的派。有F个朋友会来参加我的派对,每个人会拿到一块派(必须一个派的一块,不能由几个派的小块拼成;可以是一整个派)。我的朋友们都特别小气,如果有人拿到更大的一块,就会开始抱怨。因此所有人拿到的派是同样大小的(但不需要是同样形状的),虽然这样有些派会被浪费,但总比...
2019-07-16 10:40:44
187
原创 001:Aggressive cows(二分搜索)
总时间限制: 1000ms 内存限制: 65536kB描述Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,…,xN (0 <= xi <= 1,000...
2019-07-15 19:27:22
213
原创 Codeforces Round #568 (Div. 2)C1. Exam in BerSU (easy version)
The only difference between easy and hard versions is constraints.A session has begun at Beland State University. Many students are taking exams.Polygraph Poligrafovich is going to examine a group o...
2019-06-20 01:07:46
404
原创 Codeforces Round #568 (Div. 2)B. Email from Polycarp
Methodius received an email from his friend Polycarp. However, Polycarp’s keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a k...
2019-06-20 01:06:45
431
原创 Codeforces Round #568 (Div. 2)A. Ropewalkers
Polycarp decided to relax on his weekend and visited to the performance of famous ropewalkers: Agafon, Boniface and Konrad.The rope is straight and infinite in both directions. At the beginning of th...
2019-06-20 01:05:13
256
原创 Codeforces Round #566 (Div. 2)B. Plus from Picture
You have a given picture with size w×h. Determine if the given picture has a single “+” shape or not. A “+” shape is described below:A “+” shape has one center nonempty cell.There should be some (at...
2019-06-15 20:17:02
270
原创 Codeforces Round #566 (Div. 2)A. Filling Shapes
You have a given integer n. Find the number of ways to fill all 3×n tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap.This picture...
2019-06-15 20:16:02
621
原创 百练-4103踩方格(dfs)
总时间限制: 1000ms 内存限制: 65536kB描述有一个方格矩阵,矩阵边界在无穷远处。我们做如下假设:a. 每走一步时,只能从当前方格移动一格,走到某个相邻的方格上;b. 走过的格子立即塌陷无法再走第二次;c. 只能向北、东、西三个方向走;请问:如果允许在方格矩阵上走n步,共有多少种不同的方案。2种走法只要有一步不一样,即被认为是不同的方案。输入允许在方格...
2019-06-15 19:15:41
190
原创 POJ-1163 The Triangle(简单dp)
Description73 88 1 02 7 4 44 5 2 6 5(Figure 1)Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at t...
2019-06-11 17:40:42
118
原创 百练-4110:圣诞老人的礼物-Santa Clau’s Gifts(贪心)
总时间限制: 1000ms 内存限制: 65536kB描述圣诞节来临了,在城市A中圣诞老人准备分发糖果,现在有多箱不同的糖果,每箱糖果有自己的价值和重量,每箱糖果都可以拆分成任意散装组合带走。圣诞老人的驯鹿最多只能承受一定重量的糖果,请问圣诞老人最多能带走多大价值的糖果。输入第一行由两个部分组成,分别为糖果箱数正整数n(1 <= n <= 100),驯鹿能承受的最大重量正整数w...
2019-06-10 23:33:31
378
原创 百练-4151:电影节(贪心)
总时间限制: 1000ms 内存限制: 65536kB描述大学生电影节在北大举办! 这天,在北大各地放了多部电影,给定每部电影的放映时间区间,区间重叠的电影不可能同时看(端点可以重合),问李雷最多可以看多少部电影。输入多组数据。每组数据开头是n(n<=100),表示共n场电影。接下来n行,每行两个整数(0到1000之间),表示一场电影的放映区间n=0则数据结束输出对每组数据输...
2019-06-10 23:15:55
235
原创 POJ 3190 Stall Reservations(贪心算法 + 优先队列)
题目链接POJ3190DescriptionOh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise time interval A…B (1 <= A <= B <= 1,000,000), whi...
2019-06-10 22:46:47
201
原创 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 18:45:22
413
原创 Codeforces Round #565 (Div. 3)B. Merge it!
You are given an array a consisting of n integers a1,a2,…,an.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where y...
2019-06-10 18:44:34
236
原创 Codeforces Round #565 (Div. 3)A. Divide it!
You are given an integer n.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times:Replace n with n2 if n is divisible by 2;Replace n with 2n3...
2019-06-10 18:43:46
209
原创 Codeforces Round #564 (Div. 2)C. Nauuo and Cards
Nauuo is a girl who loves playing cards.One day she was playing cards but found that the cards were mixed with some empty ones.There are n cards numbered from 1 to n, and they were mixed with anothe...
2019-06-08 03:33:33
285
原创 Codeforces Round #564 (Div. 2)B. Nauuo and Chess
Nauuo is a girl who loves playing chess.One day she invented a game by herself which needs n chess pieces to play on a m×m chessboard. The rows and columns are numbered from 1 to m. We denote a cell ...
2019-06-08 03:32:36
364
原创 Codeforces Round #564 (Div. 2)A. Nauuo and Votes
Nauuo is a girl who loves writing comments.One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.It’s known that there were x persons who would upvote, y ...
2019-06-08 03:31:37
123
原创 Educational Codeforces Round 66 (Rated for Div. 2)C. Electrification
At first, there was a legend related to the name of the problem, but now it’s just a formal statement.You are given n points a1,a2,…,an on the OX axis. Now you are asked to find such an integer point...
2019-06-06 20:35:04
194
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人