题解下次一定(咕咕咕)
比赛链接
emmm这几天忙着看《海绵宝宝》
//A.秋季特惠
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
int T;
cin >> T;
while (T --)
{
int k, n, w;
cin >> k >> n >> w;
int need = (1 + w) * w * k / 2;
if (need <= n) cout << 0;
else cout << need - n;
cout << endl;
}
return 0;
}
//B.找工作
#include <bits/stdc++.h>
#define int long long
#define maxn 105
using namespace std;
int a[maxn];
signed main()
{
int T;
cin >> T;
while (T --)
{
int n;
cin >> n;
memset(a, 0, sizeof a);
for (int i = n; i >= 0; i --)
{
cin >> a[i];
a[i] *= i;
}
int flag = n + 5;
for (int i = n; i >= 0; i --)
{
if (a[i])
{
flag = i;
break;
}
}
if (flag == n + 5)
{
cout << 0 << endl;
continue;
}
for (int i = flag; i >= 1; i --)
{
if (i == flag) cout << a[i];
else cout << ' ' << a[i];
}
cout << endl;
}
return 0;
}
//C.购物计划
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin >> T;
while (T --)
{
int n;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i ++)
{
if (i == n) cout << 1 << endl;
else cout << 1 << ' ';
}
}
return 0;
}
//D.蟹黄堡的配方
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin >> T;
while (T --)
{
int n;
cin >> n;
string a, b;
cin >> a >> b;
bool flag = 0;
for (int i = 0; i < n; i ++)
{
if (a[i] < b[i])
{
flag = 1;
break;
}
}
if (flag) cout << -1 << endl;
else cout << b << endl;
}
return 0;
}
//E:大圈圈
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin >> T;
while (T --)
{
int n;
cin >> n;
cout << n * (n - 1) + 2 << endl;
}
return 0;
}
//F:恶龙与勇者
#include <bits/stdc++.h>
#define int long long
using namespace std;
struct power_price
{
int power;
int price;
};
bool cmp(power_price x, power_price y)
{
return x.price < y.price;
}
const int maxn = 10000 + 5;
power_price warrior[maxn];
int dragon[maxn];
signed main()
{
int T;
cin >> T;
while (T --)
{
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i ++)
{
cin >> dragon[i];
}
int wrrior_power_max = 0;
for (int i = 0; i < m; i ++)
{
cin >> warrior[i].power >> warrior[i].price;
if (warrior[i].power > wrrior_power_max)
{
wrrior_power_max = warrior[i].power;
}
}
sort(dragon, dragon + n);
sort(warrior, warrior + m, cmp);
if (dragon[n - 1] > wrrior_power_max)
{
puts("Kingdom fall");
continue;
}
int i = 0, j = 0, ans = 0;
while (i != n)
{
if (dragon[i] > warrior[j].power)
{
j ++;
}
else
{
ans += warrior[j].price;
i ++;
}
}
cout << ans << endl;
}
return 0;
}
//G.搭积木
#include <bits/stdc++.h>
#define int long long
using namespace std;
int temp, ans;
signed main()
{
int n;
cin >> n;
for (int i = 0; i < n; i ++)
{
int x;
cin >> x;
if (x > temp)
{
ans += x - temp;
}
temp = x;
}
cout << ans << endl;
return 0;
}
//H.一条数学题
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e7 + 5;
bool f[maxn];
int num[maxn];
typedef pair<int,int> PII;
signed main()
{
int n, m;
while (cin >> n>> m)
{
memset (f, 0, sizeof f);
memset (num, 0, sizeof num);
vector <PII> p;
int cnt = -1;
for(int i = 0; i <= m; i ++)
{
for(int j = 0; j <= m; j ++)
{
int temp = i * i + j * j;
if(! f[temp])
{
f[temp] = 1;
num[++ cnt] = temp;
}
}
}
sort(num, num + cnt);
for(int i = 0; i <= cnt - n + 1; i ++)
{
for(int j = i + 1; j <= cnt; j ++)
{
int b = num[i], a = num[j] - b, t;
for(t = 2; t < n; t ++)
{
if(! f[num[i] + t * a])
break;
}
if(t == n)
{
p.push_back({
a, b});
}
}
}
if (p.empty())
{
cout << "NONE" << endl << endl;
continue;
}
sort(p.begin(), p.end());
for(auto t : p)
{
cout << t.second << " " << t.first << endl;
}
cout << endl;
}
return 0;
}