题意:给一个n长度的整数,删掉 k 个数字,使得剩下的数字最大. 分析:还剩 n-k 个数字,就是在原序列里面,相对顺序不变的情况下,这个n-k个数字组成的数最大. 感觉没有什么特别好的方法策略,看了一下方案,策略是: 不断的调整这n-k个数字,感觉这个时间复杂度受不了,哈哈~~~ 如何调整:当我确定的 K 个数字 + 还剩下的 n - i 个数字 > n - k ,那么这里就会有调整,调整到恰好 >= c 的位置处. #include <bits/stdc++.h> using…
[题目描述] Elections are coming. You know the number of voters and the number of parties — n and m respectively. For each voter you know the party he is going to vote for. However, he can easily change his vote given a certain amount of money. In particu…
题意:输入1~N的一个排列,每次可以交换2个整数,问使排列变成1~N的一个环状排列所需的虽少交换次数.(3≤N≤500) 解法:(又是一道我没打代码,光想和看就花了很久时间的题~QwQ)由于n很小,可以暴力枚举目标的环状排列,于是贪心交换--把元素 x 直接与它的目标位置上的元素互换,这样至少使1个元素的位置正确了.而若 x 先与其他 k 个元素交换,是最多能得到 k+1 个元素的正确排列的,这样并没有之前的策略优. 另外,网上关于此题还有一种关于对链状序列找环的说法,我更加不理解.若有人…
Juliano is a fan of the TV show Erasing and Winning, where participants are selected in a draw and receive money for taking part in the show. In the show, the presenter writes a number of N digits in a board. The participant must then erase exactly D…
Roman Numerals The original system of writing numbers used by the early Romans was simple but cumbersome. Various letters were used to represent important numbers, and these were then strung together to represent other numbers with the values decr…
B. Computer Game 题目连接: http://www.codeforces.com/contest/37/problem/B Description Vasya's elder brother Petya loves playing computer games. In one of his favourite computer games Petya reached the final level where a fight with the boss take place. W…
题意:给出一个字符串,包含0.1.*,当中×是能够替换成0或者1的,假设字符串的某个子串S有SSS这种连续反复3次出现,不是Triple-free串,问给出的字符串能够形成多少个非Triple-free串. 题解:由于串长度最多31,所以能够暴力枚举每一位,边枚举边推断. #include <stdio.h> #include <string.h> const int N = 35; char str[N], str2[N]; int n; long long res; bool…
Selecting courses Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 62768/32768 K (Java/Others) Total Submission(s): 1856 Accepted Submission(s): 469 Problem Description A new Semester is coming and students are troubling for selecting c…
这道题我很快就写出来了, 但是一直WA, 然后发现是精度, 这坑了我一个小时-- (1)贪心.每次就尽量分数高, 可以保证最后分数最高 (2)神tm精度问题.记住判断大于小于和等于的时候要用EPS(1e-6) a == b fabs(a-b) < EPS a != b fabs(a-b) > EPS a < b a + EPS < b a <= b …
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 考虑删掉第i位. 则第i+1位就会取代第i位. 则肯定第i+1位比第i位大的话,才比较好. 则从小到大贪心删,找到第一个a[i+1]>a[i]的i. 然后每次删掉这样的i就可以了. [代码] /* 1.Shoud it use long long ? 2.Have you ever test several sample(at least therr) yourself? 3.Can you promise that the s…
A B C 给你N(N<=30)种水瓶每种水瓶有无限个 每个的体积是2^(i-1)价格是cost[i] 要求你花最少的钱弄出L体积的水 先从前到后扫一遍cost[i+1]=min(cost[i+1],cost[i]*2) 再从后往前扫一遍cost[i]=min(cost[i],cost[i+1) 保证了价格的最优化 然后从0开始到30 如果二进制有当前体积的就买 同时检验一下anser=min(anser,cost[i+1])(意思是如果买当前所有体积两倍的水比买当前的便宜就买当前体积两倍的)…