题意:给你\(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…
题意:给你两个长度为\(n\)的数组\(a\)和\(b\),元素值在\([0,n-1]\),可以对\(b\)数组的元素任意排序,求新数组\(c\),满足\(c_i=(a_i+b_i)\ mod\ n\),并且使得其字典序最小. 题解:这种取模求最小的题,我们一眼就能看出最优情况一定是\(b_i=n-a_i\),可以先用set存一下\(b\)中的元素,然后在set中二分找\(\ge \ n-a_i\)的值,因为\(a_i\)加上一个比\(n-a_i\)小的数再取模一定\(\ge a_i\),但是加…
Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such th…
Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n 和你两场分赛的排名 x, y,问你最终名次最小和最大可能是多少. 思路: 以8人为例: x + y = 2,最小第一名,最大第一名:               1 2 3 4 5 6 7 8 8 7 6 5 4 3 2 1               x + y = 3,最小第一名,最大第二名.…
比赛链接: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\)的最小乘积. 分析 容易知道结论,要使乘积变小,一定是要将尽可能多的减少量放到某一个数,而不是将减少量均摊给两个数.[*不完全证明见后] 由此,最…
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute…
D. Minimum number of steps time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of s…
A. Minimum Difficulty time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike is trying rock climbing but he is awful at it. There are n holds on the wall, i-th hold is at height ai off the g…
一 题面 E. Minimum Array 二 分析 注意前提条件:$0 \le  a_{i} \lt n$ 并且 $0 \le  b_{i} \lt n$.那么,我们可以在$a_{i}$中任取一个数进行分析,发现为满足字典序最小,在$b$中找到$n-a_{i}$就是最优解. 接下来分析$b$,在$b$中是不一定找得到$n-a_{i}$的.所以需要分析如何找到此情况下的最优解. 假设$a_{i} = 3$,$n = 4$,那么$b_{i}$对应的最优情况是$b_{i} = 1$,可以把所有$b_…