# 牛客练习赛28

https://www.nowcoder.com/acm/contest/200#question

A

#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e6 + 5;
const int M = 5e5 + 5;
struct per{
string name;
int birth;
per(string _name,int _birth){

name = _name;
birth = _birth;
}
};
bool cmp(per a,per b){
return a.birth < b.birth;
}
map<int,vector<per> > mp;
int main()
{
int n, m;
cin >> n >> m;

string tn,ty;

while(n --){
cin >> tn >> ty;
int year = 0;
for(int i = 0;i < 4;i ++){
year *= 10;
year += ty[i] - '0';
}

int date = 0;
for(int i = 4;i < 8;i ++){
date *= 10;
date += ty[i] - '0';
}

mp[date].push_back(per(tn,year));
}

int k;
string q;
while(m --){
cin >> k >> q;
int iq = 0;
for(int i = 0;i < q.size();i ++){
iq *= 10;
iq += q[i] - '0';
}

sort(mp[iq].begin(),mp[iq].end(),cmp);

cout << mp[iq][k-1].name << endl;
}
return 0;
}


B

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define maxn 10005
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1

void pushup(long long root)
{
tree[root][0]=tree[root<<1][0]+tree[root<<1|1][0];
tree[root][1]=tree[root<<1][1]+tree[root<<1|1][1];
}
void pushdown1(long long l,long long r,long long root)
{  //加法下推
{
long long x=tree[root<<1][0];
long long y=tree[root<<1|1][0];
}
}
void pushdown2(long long l,long long r,long long root)
{  //乘法下推
{
}
}
void build(long long l,long long r,long long root)
{
if(l==r)
{
scanf("%lld",&tree[root][0]);
tree[root][1]=tree[root][0]*tree[root][0];
return;
}
long long mid=(l+r)>>1;
build(lson);
build(rson);
pushup(root);
}
void update1(long long L,long long R,long long C,long long l,long long r,long long root)
{  //加法更新
if(L<=l&&r<=R)
{
long long x=tree[root][0];
tree[root][0] += (r-l+1)*C;
tree[root][1] += 2*x*C+(r-l+1)*C*C;
return ;
}
long long mid = (l+r)/2;
pushdown1(mid-l+1,r-mid,root);
if(L<=mid)
update1(L,R,C,lson);
if(R>mid)
update1(L,R,C,rson);
pushup(root);
}
void update2(long long L,long long R,long long C,long long l,long long r,long long root)
{  //乘法更新
if(L<=l&&r<=R)
{
tree[root][0] *= C;
tree[root][1] *= C*C;
return ;
}
long long mid = (l+r)/2;
pushdown2(mid-l+1,r-mid,root);
if(L<=mid)
update2(L,R,C,lson);
if(R>mid)
update2(L,R,C,rson);
pushup(root);
}
long long query(long long L,long long R,long long c,long long l,long long r,long long root)
{
if(L<=l&&R>=r)
{
if(c==1)
return tree[root][0];
if(c==2)
return tree[root][1];
}
long long ans=0,mid=(l+r)>>1;
pushdown1(mid-l+1,r-mid,root);
pushdown2(mid-l+1,r-mid,root);
if(L<=mid)
ans+=query(L,R,c,lson);
if(R>mid)
ans+=query(L,R,c,rson);
return ans;
}

int main()
{
cin>>n>>m;
build(1,n,1);
while(m--)
{
long long op,x,y,val;
scanf("%lld",&op);
if(op==1||op==2)
{
scanf("%lld%lld",&x,&y);
printf("%lld\n",query(x,y,op,1,n,1));
}
else if(op==3||op==4)
{
scanf("%lld%lld%lld",&x,&y,&val);
if(op==3)
update2(x,y,val,1,n,1);
else
update1(x,y,val,1,n,1);
}
}
return 0;
}

E

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;
const double g = 9.80665;
int main() {
int T;
scanf("%d", &T);

while (T--) {
double h, v;
scanf("%lf%lf", &h, &v);
double vt = sqrt(1.0*v*v + 2.0*g*h);
double ans = 1.0*v*vt/g;
printf("%.5f\n", ans);
}
return 0;
}

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120