目录
B-B-Mr.Maxwell and attractions
A-A Warm Welcome
没啥可说的,签到题
#include<iostream>
using namespace std;
int main(){
cout<<"Shenzhen Institute of Computing Sciences"<<endl;
return 0;
}
B-B-Mr.Maxwell and attractions
题意:Maxwell要么上午工作,下午去参加活动,要么下午工作,上午去参加活动。参加活动会获得美丽值。
- 上午第一次参加某活动-美丽值为b,下午第一次参加某室外活动-美丽值为0.8b
- 只要某活动之前参加过(不分上下午),再次参加美丽值就变成了0.6b
- 共有t天可以供你安排,上午工作 这种安排大于等于k天
问你Maxwell怎么安排美丽值最大
思路:
想要让美丽值最大,outdoor活动应尽量安排在上午(不用乘0.8了),indoor就安排在下午。
由第三条约束可知,上午参观的天数最多为t-k天。
#include<bits/stdc++.h>
#include <cstdio>
typedef long long ll;
typedef long double ld;
#define pr pair<int,int>
#define ios ios::sync_with_stdio(false)
const int SIZE=1e6+6;
const int INF=0x3f3f3f;
using namespace std;
int main()
{
int n,m,k,t,temp;
cin>>n>>m>>t>>k;
k=t-k;//上午最多参观的次数
priority_queue<ld>q1,q2;//q1代表in,q2为out
for(int i=0;i<n;i++)cin>>temp,q1.push(temp);
for(int i=0;i<m;i++)cin>>temp,q2.push(temp);
//此步骤过后,已经排序完成
ld ans=0;
while(t--){
ld a=q1.top(),b=q2.top(),flag=k?1:0.8;//只要k不等于0,即上午工作的天数不为0,倍数就为1
//否则就只能把参观安排在下午,倍率为0.8了
if(a>=b*flag)q1.pop(),q1.push(a*0.6),ans+=a;//默认下午室内参观所以k不用动
else q2.pop(),q2.push(b*0.6),k&&(k--),ans+=b*flag;
}
cout<<fixed<<setprecision(2)<<ans<<endl;
}
C-C-Hamster and Equation
将x1(x1+1)+x2(x2+1)的值作为map的键,出现次数作为键值,根据题里的等式,若map中存在k(x1(x1+1)+x2(x2+1)),对其出现次数进行累加即为答案。
#include<bits/stdc++.h>
#define ll long long
typedef long double ld;
#define pr pair<int,int>
#define ios ios::sync_with_stdio(false)
const int SIZE=1e6+6;
const int INF=0x3f3f3f;
using namespace std;
inline int read()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0' && ch<='9')
x=x*10+ch-'0',ch=getchar();
return x*f;
}
int t,n,k;
map<ll,int>p;
void solve(){
for(int i=-n;i<=n;i++){
for(int j=-n;j<=n;j++){
p[i*i+i+j*j+j]++;
}
}
ll ans=0;
for(int i=-n;i<=n;i++){
for(int j=-n;j<=n;j++){
ans+=p[(i*i+i+j*j+j)*k];
}
}
cout<<ans<<endl;
}
int main()
{
t=read();
while(t--){
n=read(),k=read();
p.clear();
solve();
}
return 0;
}
D-D-WA
对原字符串中的每个a???...a进行维护即可