CodeCraft-19 and Codeforces Round #537 (Div. 2)
Posted chunibyo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeCraft-19 and Codeforces Round #537 (Div. 2)相关的知识,希望对你有一定的参考价值。
CodeCraft-19 and Codeforces Round #537 (Div. 2)
1 #include<bits/stdc++.h> 2 using namespace std; 3 4 char a[1005],b[1005]; 5 int x,y; 6 7 int check(char&c) { 8 if(c==‘a‘||c==‘e‘||c==‘i‘||c==‘o‘||c==‘u‘) return 1; 9 else return -1; 10 } 11 12 int main() { 13 int flag=1; 14 scanf("%s %s",a,b); 15 int x=strlen(a),y=strlen(b); 16 if(x!=y) cout<<"No"<<endl; 17 else { 18 for(int i=0; i<x; ++i) { 19 if(check(a[i])*check(b[i])>0) ; 20 else { 21 flag=0; 22 cout<<"No"<<endl; 23 break; 24 } 25 } 26 if(flag) cout<<"Yes"<<endl; 27 } 28 }
B. Average Superhero Gang Power
#include<bits/stdc++.h> using namespace std; const int MAXN=1e6+5; long long n,m,k,a[MAXN]; long double sum=0.0; long double ans=0.0; int main() { scanf("%d %d %d",&n,&k,&m); for(int i=1; i<=n; ++i) { scanf("%d",&a[i]); sum+=(long double)a[i]; } sort(a+1,a+1+n); ans=(sum+min(n*k,m))/(n); for(int i=1; i<=min(n-1,m); ++i) { sum-=a[i]; ans=max(ans,(sum+min((n-i)*k,m-i))/(long double)(n-i)); } printf("%.20Lf ",ans); }
1 #include<bits/stdc++.h> 2 #define mem(a,x) memset(a,x,sizeof(a)) 3 #define ll long long 4 using namespace std; 5 6 const int MAXN=1e5+5; 7 8 ll n,k,A,B,cnt,a[MAXN]; 9 10 ll query(ll l,ll r) { 11 if(r<l) return 0; 12 ll num=upper_bound(a,a+cnt,r)-lower_bound(a,a+cnt,l); 13 if(num==0) return A; 14 ll tmp=1ll*num*B*(r-l+1); 15 if(l==r) return tmp; 16 ll mid=(l+r)>>1; 17 return min(tmp,query(l,mid)+query(mid+1,r)); 18 } 19 20 int main() { 21 cnt=0,mem(a,0); 22 scanf("%d %d %d %d",&n,&k,&A,&B); 23 for(int i=1; i<=k; ++i) scanf("%d",&a[cnt++]); 24 // for(int i=1; i<=MAXN-2; ++i) a[i]=max(a[i],a[i-1]); 25 sort(a,a+cnt); 26 cout<<query(1,1<<n)<<endl; 27 }
以上是关于CodeCraft-19 and Codeforces Round #537 (Div. 2)的主要内容,如果未能解决你的问题,请参考以下文章
CodeCraft-19 and Codeforces Round #537 (Div. 2)
CodeCraft-19 and Codeforces Round #537 (Div. 2) A - Superhero Transformation
CodeCraft-19 and Codeforces Round #537 (Div. 2) - D. Destroy the Colony(动态规划+组合数学)
CodeCraft-19 and Codeforces Round #537 (Div. 2) 题解
CodeCraft-19 and Codeforces Round #537 (Div. 2) B. Average Superhero Gang Power