A Who is The 19th ZUCCPC Champion
- 直接输出字符串就行
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<"Ranni the Witch\n";
return 0;
}
B Jiubei and Overwatch
- 题意:有n个怪,前k秒每秒可以群伤x,之后群伤y,求干掉所有怪需要的最少时间
- 思路:先找出血最厚的怪,然后分类讨论,<kx直接做除法,不够的话-kx再除y,注意取整即可。
#include<bits/stdc++.h>
using namespace std;
int main(){
int T; cin>>T;
while(T--){
int n, k, x, y; cin>>n>>k>>x>>y;
int mx; cin>>mx;
for(int i = 2; i <= n; i++){
int t; cin>>t; mx = max(mx, t);
}
if(k*x>=mx){
int t = mx/x;
if(mx%x!=0)t++;
cout<<t<<"\n";
}else{
mx -= k*x;
int t = k+mx/y;
if(mx%y!=0)t++;
cout<<t<<"\n";
}
}
return 0;
}
C Ah, It’s Yesterday Once More
- 题意:给出两段冒泡排序的伪代码,求构造一个长为n的排列(不重),满足使用两段代码排序的交换次数相同。
- 思路:对于冒泡排序,其交换次数= 逆序对数量,可以发现若构造的排列a1 = n,两个算法的交换次数都是其逆序对数量。 所以随便输出一个首位为n 的排列即可。
#include<bits/stdc++.h>
using namespace std;
int main(){
int T; cin>>T;
while(T--){
int n; cin>>n;
for(int i = n; i >= 1; i--){
cout<<i<<" ";
}
cout<<"\n";
}
return 0;
}
F Sum of Numerators
- 题意:T组(1e5)数据,每次给出n, k(1e9),求1~n所有数除以pow(2,k)后分母部分相加的结果。
- 思路:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int T; cin>>T;
while(T--){
LL n, k; cin>>n>>k;
LL sum = n*(n+1)/2;
while(n>0 && k>0){
n >>= 1;
sum -= n*(n+1)/2;
k--;
}
cout<<sum<<"\n";
}
return 0;
}
L Monster Tower
- 题意:T组数据(1e5),每次给出一个长度为n(1e5)的序列和k。假设主角初始有x点伤害,每次可以在底下的k层选择血量低于x的ai打败,并获得ai点伤害的增加,然后后面的序列顺位补上。求初始状态下最少有多少伤害x可以打完所有的怪。
- 思路:
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
typedef long long LL;
const int maxn = 2e5+10;
LL a[maxn];
int main(){
IOS;
int T; cin>>T;
while(T--){
int n, k; cin>>n>>k;
multiset<LL>se;
for(int i = 1; i <= n; i++){
cin>>a[i];
if(i<k)se.insert(a[i]);
}
LL x = 0, ans = 0;
for(int i = 1; i <= n; i++){
if(i+k-1<=n)se.insert(a[i+k-1]);
LL t = *se.begin();
if(x >= t)x += t;
else{
ans += t-x;
x += t-x;
x += t;
}
// cout<<(*se.begin())<<" "<<x<<" "<<ans<<"\n";
se.erase(se.begin());
}
cout<<ans<<"\n";
}
return 0;
}