0%

E. Beautiful Array

思路讲解

一个小的脑筋急转弯

构造数组为 b b 3a-2b

无论3a-2b 的值是多少,b都是中位数

AC代码

https://codeforces.com/contest/2041/submission/293763683

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

using namespace std;
typedef long long ll;
ll a,b;

int main() {
cin>>a>>b;
// its mean is exactly a
// and its median is exactly b
// 怎么做才能达到这样的效果那?
cout<<3<<"\n";
cout<<b<<" "<<b<<" "<<3*a-(2*b)<<endl;
}
// AC https://codeforces.com/contest/2041/submission/293763683

心路历程(WA,TLE,MLE……)