ABC 283 ABCD
https://atcoder.jp/contests/abc283
A - Power
题目大意:
输出a的b次方。
Sample Input 1
4 3
Sample Output 1
64
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=500200,M=2002;
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
LL T=1;
//cin>>T;
while(T--)
{
LL a,b;
cin>>a>>b;
LL sum=pow(a,b);
cout<<sum<<endl;
}
return 0;
}
B - First Query Problem
题目大意:
给定长度为n的序列A,q个操作,每个操作中是以下两种之一:
1 k x : A[k]=x;
2 k : 输出A[k]。
Sample Input 1
3
1 3 5
7
2 2
2 3
1 3 0
2 3
1 2 8
2 2
2 1
Sample Output 1
3
5
0
8
1
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=500200,M=2002;
LL a[N];
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
LL T=1;
//cin>>T;
while(T--)
{
LL n;
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
LL q;
cin>>q;
while(q--)
{
LL op;
cin>>op;
if(op==1)
{
LL k,x;
cin>>k>>x;
a[k]=x;
}
else
{
LL k;
cin>>k;
cout<<a[k]<<endl;
}
}
}
return 0;
}
C - Cash Register
题目大意:
给定一个字符串s由数字组成,11 keys: 00, 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9
问我们打出这个字符串最少要按多少个键?
Sample Input 1
40004
Sample Output 1
4
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=500200,M=2002;
LL a[N];
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
LL T=1;
//cin>>T;
while(T--)
{
string s;
cin>>s;
LL sum=0;
for(int i=0;i<s.size();i++)
{
if(s[i]=='0'&&s[i+1]=='0') i++;
sum++;
}
cout<<sum<<endl;
}
return 0;
}
D - Scope
题目大意:
在所有括号都成功配对的情况下,字母的气球不能重复:
(:不做任何操作
):拿完直到和此右括号匹配的左括号
字母:这里还留有同一个字母的就不行,没有就行
Sample Input 1
((a)ba)
Sample Output 1
Yes
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=500200,M=2002;
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
LL T=1;
//cin>>T;
while(T--)
{
string s;
cin>>s;
vector<char> v;
map<char,LL> mp;
bool flag=true;
for(int i=0;i<s.size();i++)
{
if(s[i]=='(') v.push_back(s[i]);
else if(s[i]==')')
{
for(int j=v.size()-1;j>=0;j--)
{
//cout<<v[j]<<endl;
if(v[j]=='(')
{
v.pop_back();
break;
}
else
{
//cout<<"sa"<<endl;
mp[v[j]]--;
v.pop_back();
}
}
}
else
{
v.push_back(s[i]);
mp[s[i]]++;
if(mp[s[i]]>=2)
{
//cout<<s[i]<<endl;
flag=false;
}
}
if(flag==false) break;
}
if(flag==false) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
return 0;
}