#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
// template<typename T> bool chmax(T & a, const T & b){return a < b ? a = b, 1 : 0;}
signed main()
{
int T; cin >> T;
while (T --)
{
vector<ll> ve(3); for (int i = 0; i < 3; i ++) cin >> ve[i];
for (int i = 0; i < 3; i ++)
{
ll sum = 0;
for (int j = 0; j < 3; j ++)
{
if (j != i) sum = max(sum, ve[j]);
}
cout << max(0LL, sum + 1 - ve[i]) << " ";
}
puts("");
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
string B[] = {"00", "25", "50", "75"};
signed main()
{
int T; cin >> T;
while (T --)
{
string S; cin >> S;
int ans = S.size(), len = ans;
for (int x = 0; x < 4; x ++)
{
int p = 1;
for (int i = len - 1; i >= 0; -- i)
{
if (S[i] == B[x][p]) p --;
if (p == -1)
{
ans = min(ans, len - i - 2); break;
}
}
}
cout << ans << "\n";
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int maxn = 4e5 + 5;
int x[maxn];
signed main()
{
int T; cin >> T;
while (T --)
{
int n, k; cin >> n >> k;
for (int i = 0; i < k; i ++)
{
cin >> x[i];
x[i] = n - x[i];
}
sort(x, x + k);
int cur = 0, ans = 0;
for (int i = 0; i < k; i ++)
{
cur += x[i];
if (cur < n) ans ++;
}
cout << ans << "\n";
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline int gcd(int a, int b){return b ? gcd(b % a, b) : a;}
const int maxn = 2e6 + 5, MOD = 1e9 + 7;
int a[maxn], vis[maxn];
signed main()
{
int T; cin >> T;
while (T --)
{
int n; cin >> n;
int MIN = MOD, st = 0;
for (int i = 0; i < n; i ++) cin >> a[i];
sort(a, a + n);
for (int i = 1; i < n; i ++)
{
if (a[i] == a[i - 1]) continue;
vis[st ++] = a[i] - a[i - 1];
}
for (int i = 1; i < st; i ++)
{
if (i == 1) MIN = __gcd(vis[0], vis[1]);
else MIN = __gcd(MIN, vis[i]);
}
if (st == 1) MIN = vis[0];
if (MIN == MOD) MIN = -1;
cout << MIN << "\n";
}
return 0;
}
// code of JUYU ^ ^ never doubt youself !
#include <bits/stdc++.h>
typedef long long ll;
#define int ll
#define For(i,a,b) for (int i = a; i <= b; i ++)
#define Dow(i,a,b) for (int i = b; i >= a; -- i)
#define ms(a,b) memset(a, b, sizeof (a))
#define fir first
#define sec second
#define mk make_pair
#define pb push_back
#define eb emplace_back
using namespace std;
typedef pair<int,int> PII;
typedef map<int,int> MII;
const int mod = 998244353;
const int MOD = 1000000007;
const int maxn = 2e6 + 5;
inline ll read()
{
ll t = 0, dp = 1; char c = getchar();
while(!isdigit(c)) {if (c == '-') dp = -1; c = getchar();}
while(isdigit(c)) t = t * 10 + c - 48, c = getchar();
return t * dp;
}
inline void write(ll x){if (x < 0){putchar('-'); x = -x;} if(x >= 10) write(x / 10); putchar(x % 10 + 48);}
inline void writeln(ll x){write(x); puts("");}
inline void write_p(ll x){write(x); putchar(' ');}
inline void write_b(ll x){putchar(' '); write(x);}
inline int gcd(int a, int b){return b ? gcd(b % a, b) : a;}
inline int lcm(int a, int b){return a * b / gcd(a, b);}
inline int qpow(int x, int y, int z){int ret = 1; for (; y; y /= 2, x = x * x % z) if (y & 1) ret = ret * x % z; return ret;}
inline int PrimeInv(int x, int y){return qpow(x, y - 2, MOD);}
bool cmp(int a, int b){return a > b;}
MII mp;
int a[maxn], vis[maxn];
int ans;
signed main()
{
int T = read();
while (T --)
{
int n = read(); bool flag = false; mp.clear();
For(i,1,n)
{
a[i] = read(); mp[a[i]] ++;
if (mp[a[i]] >= n / 2) flag = true;
}
if (flag) puts("-1");
else
{
ans = 0;
For(i,1,n)
{
int sum = 0, MAX = 0;
For(j,1,n)
{
if (a[j] == a[i]){sum ++; continue;}
if (a[j] > a[i])
{
int t = a[j] - a[i];
for (int k = 1; k * k <= t; k ++)
{
if (t % k == 0)
{
vis[k] ++;
if (k * k != t) vis[t / k] ++;
}
}
}
}
For(i,1,2e6)
{
if (vis[i] + sum >= n / 2)
{
ans = max(ans, i);
}
vis[i] = 0;
}
}
writeln(ans);
}
}
return 0;
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
-- Benq
*/
#include <bits/stdc++.h>
using namespace std;
int n, a, b;
string s;
const int maxn = 42;
int vis[maxn][maxn][maxn][maxn];
int stc[maxn], colors[maxn];
int ans;
void lui(int id, int mod_a, int mod_b, int num_a)
{
if (id == n)
{
if (mod_a == 0 && mod_b == 0 && num_a > 0 && num_a < n)
{
if (abs(n - 2 * num_a) < ans)
{
ans = abs(n - 2 * num_a);
for (int i = 0; i < n; ++ i) colors[i] = stc[i];
}
}
return ;
}
if (vis[id][mod_a][mod_b][num_a] == 1) return ;
vis[id][mod_a][mod_b][num_a] = 1;
stc[id] = 0;
lui(id + 1, (mod_a * 10 + s[id] - '0') % a, mod_b, num_a + 1);
stc[id] = 1;
lui(id + 1, mod_a, (mod_b * 10 + s[id] - '0') % b, num_a);
return ;
}
signed main()
{
int T; cin >> T;
while (T --)
{
cin >> n >> a >> b;
cin >> s;
memset(vis, 0 , sizeof vis);
ans = 1e9;
lui(0, 0, 0, 0);
if (ans != 1e9)
{
for (int i = 0 ; i < n ; i ++)
{
if (colors[i] == 0) cout << "R";
else cout << "B";
}
puts("");
}
else puts("-1");
}
return 0;
}
其实$E$比$d2$简单多了QWQ
赛时D2也是卡了我一阵思路,F最后没码出来,想复杂了hh
好强好强!!
嘿嘿,小飞龙聚聚,嘿嘿^_^