题意:给你两个数字\(x\)和\(y\),让你构造一个长度为\(n\)的序列,要求包含\(x\)和\(y\),并且排序后相邻两项的差值相等. 题解:有排序后相邻两项的差值相等可知,构造的序列排序后一定是一个等差数列,而题目给的\(x\)和\(y\)的范围很小,所以我们可以从\([1,50]\)来枚举公差\(d\),这个\(d\)必须要能整除\(x\)和\(y\)的差值,并且\([x,y]\)的所有数的个数整除\(d\)上取整后不大于\(n\),这样找到的第一个\(d\),一定是最优解,直接构造输…
比赛链接:https://codeforces.com/contest/1409 A. Yet Another Two Integers Problem 题意 给出两个数 $a$ 和 $b$,有以下两种操作: $a+=k$ $a-=k$ $k \in [1, 10]$ 问将 $a$ 变为 $b$ 最少需要操作多少次. 题解 $a,b$ 之差的绝对值对 $10$ 取上整. 代码 #include <bits/stdc++.h> using namespace std; void solve()…
抱歉B.C题咕了这么久 B. Minimum Product #枚举 #贪心 题目链接 题意 给定四个整数\(a, b, x, y\),其中\(a\geq x, b\geq y\),你可以执行不超过\(n\)次的操作:选择\(a\)或者\(b\),减一.操作保证\(a\)不会低于\(x\),\(b\)不会低于\(y\).现要你求出\(a\)与\(b\)的最小乘积. 分析 容易知道结论,要使乘积变小,一定是要将尽可能多的减少量放到某一个数,而不是将减少量均摊给两个数.[*不完全证明见后] 由此,最…
题意:有\(n\)个点往下落,你可以在最下面放两个长度为\(k\)的板子,问做多能接到多少个点. 题解:这题给纵坐标\(y\)完全没有用,我们先对横坐标\(x\)排序,然后从左边开始枚举,用\(l[i]\)记录\([1,i]\)中,一块板子最多能接到的点,然后再从右开始枚举,用\(r[i]\)记录\([i,n]\)中,一块板子最多能接到的点,最后遍历所有横坐标,维护\(l[i]+r[i+1]\)的最大值即可,其实可以理解为\(l[]\)就是第一块板子,\(r[]\)就是第二块板子. 代码: in…
题意:给你一个正整数\(n\),每次可以对\(n\)加一,问最少操作多少次是的\(n\)的所有位数之和不大于\(s\). 题解:\(n\)的某个位置上的数进位,意味这后面的位置都可以被更新为\(0\),所以我们从高位往低位记录一个\(sum\),然后根据情况判断即可. 代码: int t; int s; ll n; char str[N]; int main() { //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); t=read(); w…
题意:给你\(a\)和\(b\)两个数,每次操作可以是任意一个数\(-1\),最多操作\(n\),并且\(a\ge x\),\(b\ge y\),求操作后\(a*b\)的最小值. 题解:观察样例并且在纸上推一推发现,我们要让\(a\)和\(b\)中,小的那个尽可能的小,然后模拟一下就好了. 代码: int t; ll a,b,x,y,n; int main() { //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); t=read(); wh…
D. Anton and School - 2 题目连接: http://codeforces.com/contest/785/problem/D Description As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn differ…
D. Soldier and Number Game Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/546/problem/D Description Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second s…
B. Chloe and the sequence 题目链接 http://codeforces.com/contest/743/problem/B 题面 Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the ol…
A. Guest From the Past 题目连接: http://www.codeforces.com/contest/625/problem/A Description Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found hi…