2019银川现场赛补题
Posted hh13579
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2019银川现场赛补题相关的知识,希望对你有一定的参考价值。
I. Base62
x,y,z = (input().split())
x = int(x)
y = int(y)
num = []
map = {}
for i in range(62):
if i < 10:
num.append(chr(i+48))
elif i < 36:
num.append(chr(i-10+65))
else:
num.append(chr(i-36+97))
map[num[i]] = i
cnt = 0
ans = []
for i in z:
t = map[i]
cnt = cnt * x + t
while cnt > 0:
ans.append(num[cnt % y])
cnt = cnt // y
if len(ans) == 0:
ans.append(0)
ans.reverse()
for i in ans:
print(i,end = "")
G. Pot!!
#include <cstdio>
#include <iostream>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
#define ll long long
#define P pair<int,int>
#define mk make_pair
const ll INF=1e18;
const int N=1e5+10;
ll a[N];
struct SegmentTree{
int l,r;
ll maxn;
ll dat;
}t[N*4][4];
void build(int p,int l,int r,int i)
{
t[p][i].l = l;
t[p][i].r = r;
t[p][i].dat = 0;
if(t[p][i].l == t[p][i].r){t[p][i].maxn = 0;return ;}
int mid = (l+r)/2;
build(p*2,l,mid,i);
build(p*2+1,mid+1,r,i);
t[p][i].maxn = max(t[p*2][i].maxn,t[p*2+1][i].maxn);
}
void spread(int p,int i)
{
if(t[p][i].dat)
{
t[p*2][i].maxn += t[p][i].dat;
t[p*2+1][i].maxn += t[p][i].dat;
t[p*2][i].dat += t[p][i].dat;
t[p*2+1][i].dat += t[p][i].dat;
t[p][i].dat = 0;
}
}
void change(int p,int l,int r,ll v,int i)
{
if(l <= t[p][i].l && t[p][i].r <= r)
{
t[p][i].dat += v;
t[p][i].maxn += v;
return ;
}
int mid = (t[p][i].l+t[p][i].r)/2;
spread(p,i);
if(l<=mid) change(p*2,l,r,v,i);
if(r>mid) change(p*2+1,l,r,v,i);
t[p][i].maxn = max(t[p*2][i].maxn,t[p*2+1][i].maxn);
}
ll ask(int p,int l,int r,int i)
{
if(l<=t[p][i].l&&r>=t[p][i].r)
return t[p][i].maxn;
int mid = (t[p][i].l+t[p][i].r)/2;
spread(p,i);
ll maxn = 0;
if(l<=mid) maxn = max(maxn,ask(p*2,l,r,i));
if(r>mid) maxn = max(maxn,ask(p*2+1,l,r,i));
return maxn;
}
vector<P>num[11];
void init()
{
int map[10];
map[2] = 0,map[3] = 1,map[5] = 2,map[7] = 3;
for(int i=2;i<=10;i++){
int x = i;
for(int j=2;j<=x;j++){
int sum = 0;
while(x%j==0){
sum++;
x = x / j;
}
if(sum){
num[i].push_back(mk(map[j],sum));
}
}
}
}
int main()
{
ios::sync_with_stdio(false);
init();
int n,q;
cin >> n >> q;
for(int i=0;i<4;i++){
build(1,1,n,i);
}
while(q--){
string s;
cin >> s;
if(s[1]==‘U‘){
int l,r,x;
cin >> l >> r >> x;
for(int i=0;i<num[x].size();i++){
change(1,l,r,num[x][i].second,num[x][i].first);
}
}
else{
int l,r;
cin >> l >> r;
int ans = 0;
for(int i=0;i<4;i++){
ans = max(ans*1LL,ask(1,l,r,i));
}
printf("ANSWER %d
",ans);
}
}
return 0;
}
以上是关于2019银川现场赛补题的主要内容,如果未能解决你的问题,请参考以下文章