题意:给定n个数,要求修改其中最少的数,使得这n个数满足ai + 1 - ai = k. 分析: 暴力,1000*1000. 1.这n个数,就是一个首项为a1,公差为k的等差数列.k已知,如果确定了a1,就能确定整个数列. 2.1 ≤ ai ≤ 1000,因此,可以从1~1000中枚举a1,将形成的数列与给定的数列比较,统计两数列对应下标中不同数字的个数. 3.不同数字的个数最少的那个数列就是最终要修改成的数列,然后输出对应下标的那个数的变化值即可. #include<cstdio> #inc…
题目链接:http://codeforces.com/problemset/problem/402/B 题目意思:给出n个数和公差k,问如何调整使得ai + 1 - ai = k.(1 ≤ i < n),即等差数列,求出最少的调整次数.(调整的操作包括向一个数添加或者减少某个数,使得后一个数-前一个数 = 公差). 方法一: 对于每一个数ai,求出以ai为基准,在ai之前和在ai之后不满足等差数列的个数.直到扫描整个序列结束,选出个数最少的,,即调整的次数最少,然后再一次扫描整个序列,算出每一个…
B. Trees in a Row time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The Queen of England has n trees growing in a row in her garden. At that, the i-th (1 ≤ i ≤ n) tree from the left has heigh…
"Cricket Field" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100002 Description Once upon a time there was a greedy King who ordered his chief Architect to build a field for royal cricket inside his park. The King was so…
M. Variable Shadowing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/M Description In computer programming, variable shadowing occurs when a variable declared within a certain scope has the same name as a variab…
G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/G Description An owner of a small company FacePalm has recently learned that the city authorities plan to offer to small businesses to partic…
A. Arya and Bran time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies…
Grigory loves strings. Recently he found a metal strip on a loft. The strip had length n and consisted of letters "V" and "K". Unfortunately, rust has eaten some of the letters so that it's now impossible to understand which letter was…
B. Lorry 题目连接: http://www.codeforces.com/contest/3/problem/B Description A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that a…
题目链接: C. Bear and Colors time limit per test 2 seconds   memory limit per test 256 megabytes input standard input output standard output Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. The…