![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
思维&&乱搞
文章平均质量分 80
键盘里的青春
加油~
展开
-
Wannafly挑战赛18 A 序列
题目描述有一个长度为n的序列a,已知a[1]=a[n]=1,且对于2 <= x <= n,a[x] / a[x-1]是以下三个数字之一 [ 1,-2,0.5 ],问有多少种不同的序列满足题意。两个序列不同当且仅当它们有至少一个位置上的数字不同,序列a可以为任何实数。输入描述:一个整数 表示n (1<= n <= 1e3)输出描述:一个整数 表示答案模109+7思路:一开始觉...原创 2018-07-03 11:11:30 · 243 阅读 · 0 评论 -
51nod 1096 距离之和最小 && 1108-距离之和最小 V2(简单数学)&& 1110 距离之和最小 V3(逆思维)
1096 距离之和最小基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注X轴上有N个点,求X轴上一点使它到这N个点的距离之和最小,输出这个最小的距离之和。Input第1行:点的数量N。(2 <= N <= 10000)第2 - N + 1行:点的位置。(-10^原创 2017-07-11 00:18:21 · 624 阅读 · 0 评论 -
★★51nod 1574 排列转换 (贪心思维题)
1574 排列转换 收藏 关注现在有两个长度为n的排列p和s。要求通过交换使得p变成s。交换 pi 和 pj 的代价是|i-j|。要求使用最少的代价让p变成s。Input单组测试数据。第一行有一个整数n (1≤n≤200000),表示排列的长度。第二行有n个范围是1到n的整数,表示排列p。每个整数只出现一次原创 2017-06-01 00:32:28 · 794 阅读 · 0 评论 -
★codeforces 612D The Union of k-Segments (思维or类扫描线)
D. The Union of k-Segmentstime limit per test 4 secondsmemory limit per test 256 megabytesinput standard inputoutput standard outputYou are given n segments on原创 2017-05-17 13:44:55 · 1046 阅读 · 0 评论 -
51nod 1821 最优集合 (思维+并查集or栈)
1821 最优集合基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注一个集合S的优美值定义为:最大的x,满足对于任意i∈[1,x],都存在一个S的子集S',使得S'中元素之和为i。给定n个集合,对于每一次询问,指定一个集合S1和一个集合S2,以及一个数k,要求选择一个S2的子集S3(|S3|原创 2017-05-16 15:04:31 · 533 阅读 · 0 评论 -
poj 1328 Radar Installation (逆思维+贪心)
Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the原创 2017-05-15 18:04:30 · 847 阅读 · 0 评论 -
CodeForces 776C Molly's Chemicals (思维+前缀)
C. Molly's Chemicalstime limit per test 2.5 secondsmemory limit per test 512 megabytesinput standard inputoutput standard outputMolly Hooper has n different kin原创 2017-04-16 16:53:30 · 663 阅读 · 0 评论 -
ZOJ 3872 Beauty of Array (思维 dp思想)
D - Beauty of ArrayTime Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluSubmit Status Practice ZOJ 3872DescriptionEdward has an array A with N integers. He defin原创 2017-05-01 20:25:30 · 448 阅读 · 0 评论 -
POJ 2182 Lost Cows 题解 (线段树维护区间变化or暴力)
Lost CowsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 11625 Accepted: 7472DescriptionN (2 <= N <= 8,000) cows have unique brands in the range 1..N.原创 2017-03-15 10:20:09 · 911 阅读 · 0 评论 -
阿里巴巴笔试题
题意:给定一串数字 判断是否存在这三个元素,它们将数字串分为四个子串,其中每个子串的数字之和均相同(该3个元素不纳入计算) 要求时间复杂度和空间复杂度均不能超过O(n)思路:奇妙的利用了单调性,枚举第一段的和, 第一段的和确定了,那么接下来的2,3,4段的和就都确定了,什么单调性呢? 就是i右移,j,k都要右移。这就是单调性了,第一段变大,那么234段都要变大,所以i,原创 2017-03-12 20:42:17 · 976 阅读 · 0 评论 -
51nod 1483 化学变换 (枚举+bfs or 枚举+技巧)
1483 化学变换题目来源: CodeForces基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注有n种不同的化学试剂。第i种有ai升。每次实验都要把所有的化学试剂混在一起,但是这些试剂的量一定要相等。所以现在的首要任务是把这些化学试剂的量弄成相等。有两种操作:·原创 2017-06-12 14:26:26 · 482 阅读 · 0 评论 -
51nod 1163 最高的奖励 (贪心+优先队列/并查集)&& 1191 消灭兔子(贪心+优先队列维护) && 1475 建设国家 (思维枚举+优先队列)
1163 最高的奖励基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注有N个任务,每个任务有一个最晚结束时间以及一个对应的奖励。在结束时间之前完成该任务,就可以获得对应的奖励。完成每一个任务所需的时间都是1个单位时间。有时候完成所有任务是不可能的,因为时间上可能会有冲突,这需要你来取舍。求能够获原创 2017-07-12 10:58:44 · 664 阅读 · 0 评论 -
HDU - 5452 Minimum Cut (lca+差分+思维)
Minimum CutTime Limit: 3000/2000 MS (Java/Others) Memory Limit: 65535/102400 K (Java/Others)Total Submission(s): 1821 Accepted Submission(s): 863Problem DescriptionGiven a simple原创 2017-09-25 16:44:13 · 293 阅读 · 0 评论 -
Codeforces 851D Arpa and a list of numbers (枚举+分段)
D. Arpa and a list of numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputArpa has found a list contain原创 2017-09-08 01:05:13 · 569 阅读 · 0 评论 -
HDU 6166 Senior Pan (思维枚举+最短路 求最近点对)
Senior PanTime Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 898 Accepted Submission(s): 361Problem DescriptionSenior Pan fai原创 2017-08-25 00:19:53 · 1034 阅读 · 0 评论 -
51nod 1435 位数阶乘 (思维水题)
1435 位数阶乘题目来源: CodeForces基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注X是一个n位数的正整数 (x=a0a1...an−1) 现在定义 F(x)=∏i=0n−1(ai!) , 比如F(135)=1!*3!*5!=720.我们给定一个原创 2017-08-18 22:09:16 · 713 阅读 · 0 评论 -
51nod 1065 最小正子段和(前缀和+思维) && 1051最大子矩阵和(枚举+最大子段和)
1065 最小正子段和基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注N个整数组成的序列a[1],a[2],a[3],…,a[n],从中选出一个子序列(a[i],a[i+1],…a[j]),使这个子序列的和>0,并且这个和是所有和>0的子序列中最小的。例如:4,-1,5,-2,-1,2原创 2017-07-26 21:52:16 · 539 阅读 · 0 评论 -
51nod 1625 夹克爷发红包(状压枚举+贪心)
1625 夹克爷发红包基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注在公司年会上,做为互联网巨头51nod掌门人的夹克老爷当然不会放过任何发红包的机会。现场有n排m列观众,夹克老爷会为每一名观众送出普通现金红包,每个红包内金额随机。接下来,夹克老爷又送出最多k组高级红原创 2017-07-10 00:01:00 · 473 阅读 · 0 评论 -
Codeforces 734E Anton and Tree (dfs缩点+树的直径)
E. Anton and Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton is growing a tree in his garden. In case yo原创 2017-07-07 18:48:59 · 713 阅读 · 0 评论 -
Codeforces 822C Hacker, pack your bags!(思维+技巧)
C. Hacker, pack your bags!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's well known that the best wa原创 2017-07-05 11:58:54 · 1860 阅读 · 0 评论 -
51nod 1449 砝码称重(思维+进制)
1449 砝码称重题目来源: CodeForces基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注现在有好多种砝码,他们的重量是 w0,w1,w2,... 每种各一个。问用这些砝码能不能表示一个重量为m的东西。样例解释:可以将重物和3放到一个托盘中,9和1放到另外一个托盘原创 2017-07-12 22:37:29 · 576 阅读 · 0 评论 -
Codeforces 367B Sereja ans Anagrams 详细题解(map应用+维护长度)
B. Sereja ans Anagrams time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Sereja has two sequences a and b and number p. Sequence a cons原创 2017-03-11 22:59:29 · 552 阅读 · 0 评论 -
codeforces 672D D. Robin Hood (二分+思维)
D. Robin Hoodtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe all know the impressive story of Robin Hood. Robin原创 2017-03-11 12:47:34 · 671 阅读 · 0 评论 -
HDU 6016 Count the Sheep(思维水题)
Count the Sheep Accepts: 227 Submissions: 805 Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)问题描述开学翘课固然快乐,然而也有让呃喵抓狂的事,那当然就是考试了!这可急坏了既要翘课又想原创 2017-02-26 11:29:30 · 593 阅读 · 0 评论 -
Codeforces 349 B Color the Fence (思维+贪心)
B. Color the Fencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIgor has fallen in love with Tanya. Now原创 2016-12-07 21:16:14 · 675 阅读 · 0 评论 -
HDU 5969 最大的位或 (思维)
最大的位或Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 691 Accepted Submission(s): 313Problem DescriptionB君和G君聊天的时候想到了如下的问题。给原创 2016-12-02 22:00:21 · 607 阅读 · 0 评论 -
HDU 5701 中位数计数 (思维+枚举技巧)
中位数计数Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1401 Accepted Submission(s): 521Problem Description中位数定义为所有值从小到大排序后排在正中原创 2016-11-18 16:26:55 · 1081 阅读 · 0 评论 -
Canada Cup 2016 D. Contest Balloons详解(贪心+优先队列)
D. Contest Balloonstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne tradition of ACM-ICPC contests is t原创 2016-11-01 21:52:07 · 722 阅读 · 0 评论 -
BZOJ2456 Mode & zju2132 The Most Frequent Number(众数性质)
Description给你一个n个数的数列,其中某个数出现了超过n div 2次即众数,请你找出那个数。Input第1行一个正整数n。第2行n个正整数用空格隔开。Output 一行一个正整数表示那个众数。Sample Input53 2 3 1 3Sample Output原创 2016-11-29 15:16:56 · 688 阅读 · 0 评论 -
Codeforces Round #378 (Div. 2) && codeforces 733D(思维枚举)
D. Kostya the Sculptortime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKostya is a genial sculptor, he has原创 2016-11-01 17:49:59 · 556 阅读 · 0 评论 -
HDU 1106 排序(简单分类模拟)
排序Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 53015 Accepted Submission(s): 15476Problem Description输入一行数字,如果我们把这行数字中的‘5’原创 2016-11-01 01:24:40 · 486 阅读 · 0 评论 -
QDU 反转数字
描述输入一个 c 语言 4字节 int 范围内的数字,输出它反转后的数字。比如12345反转后是54321,-12345反转后是-54321。如果反转后的数字不在 int 范围内就输出0;输入每行一个 int 范围内的数字,以 EOF 结尾。输出输出反转后的数字,每行一个注意:带着pow运算很容易很容易有误差,最好都是手写po原创 2016-08-30 21:56:46 · 788 阅读 · 1 评论 -
QDU easy problem(另类枚举)
描述给你一个数字N,N的范围是1~1000000,求一个最小的正整数M,这个数字M的各个位的数字加上它本身之和恰好为N。当然,如果没有解,输出0。输入输入数据由多组数据组成,每行由一个数字N组成(1输出对于每组数据,输出仅一行包含一个整数M。如果对于每个N,存在最小的M,则输出这个最小值。如果不存在这个最小的M,则输出0。样例输入原创 2016-08-31 16:23:18 · 650 阅读 · 0 评论 -
Codeforces Round #383 (Div. 2) && Codeforces 742 B (标记技巧)
B. Arpa’s obvious problem and Mehrdad’s terrible solutiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTh原创 2016-12-07 21:27:31 · 607 阅读 · 0 评论 -
Codeforces Round #209 (Div. 2) B && Codeforces 359 B(构造)
B. Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation p is an ordered group of number原创 2016-11-27 21:10:02 · 436 阅读 · 0 评论 -
Codeforces Round #395 (Div. 2) D Timofey and rectangles(思维题)
D. Timofey and rectanglestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne of Timofey's birthday present原创 2017-02-03 23:24:12 · 836 阅读 · 0 评论 -
Codeforces Round #395 (Div. 2) C. Timofey and a tree (树的基础应用)
C. Timofey and a treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEach New Year Timofey and his friends原创 2017-02-03 23:17:22 · 1173 阅读 · 0 评论 -
CodeForces 363D Renting Bikes (二分+贪心)
D. Renting Bikestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA group of n schoolboys decided to ride bik原创 2017-02-24 13:06:37 · 559 阅读 · 0 评论 -
Educational Codeforces Round 17 C && codeforces 762C C. Two strings 详细的题解 (前后缀应用)
C. Two stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two strings a and b. You hav原创 2017-02-02 13:39:24 · 1171 阅读 · 0 评论 -
Codeforces Round #210 (Div. 2) C. Levko and Array Recovery && Codeforces 360 A 详解(思维+维护理论值)
C. Levko and Array Recoverytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLevko loves array a1, a2, ...原创 2017-02-23 14:07:31 · 683 阅读 · 0 评论