首页 > 其他分享 >ABC 283 ABCD

ABC 283 ABCD

时间:2022-12-25 12:11:34浏览次数:58  
标签:ABCD typedef ABC const cout LL cin long 283

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;
}

标签:ABCD,typedef,ABC,const,cout,LL,cin,long,283
From: https://www.cnblogs.com/Vivian-0918/p/17003849.html

相关文章

  • AT_abc227_c [ABC227C] ABC conjecture 翻译
    题目传送门题目描述给出正整数$N$。求$A\leq\B\leq\C$并且$ABC\leq\N$的正整数对$(A,B,C)$的个数。注意,在限制条件下,保证答案小于$2^{63}$。输入......
  • AT_abc279_a [ABC279A] wwwvvvvvv 题解
    题目传送门题目大意给定仅由v和w构成的字符串\(S\),输出\(S\)中有几处向下凸出的部分。解题思路v有一处向下凸出的部分,w有两处向下凸出的部分,所以如果\(S_i\)......
  • AtCoder Beginner Contest 283
    A-Power(abc283a)题目大意给定\(A,B\),输出\(A^B\)解题思路数不大,暴力即可。数大了可用快速幂。神奇的代码#include<bits/stdc++.h>usingnamespacestd;us......
  • abc--283--E
    关键跟炮兵阵地那道题目很像,先确定上面哪一行的状态,然后在确定下面这一行的状态,采用dp就可以枚举所有的状态代码#include<bits/stdc++.h>usingnamespacestd;const......
  • abc 283 E Don't Isolate Elements
    abc283EDon'tIsolateElements题意:给出一个\(h*w\)的01矩阵,对于每一行,可以进行翻转操作。如果\(a_{i,j}\)的上下左右没有一个和它数值一样的话,这个点就被称......
  • Acwing 第 83 场周赛 ABC
    https://www.acwing.com/activity/content/competition/problem_list/2714/4785.奇偶题目大意:给定一个字符串,问我们去重后单词数是奇是偶?输入样例1:wjmzbmr输出样......
  • abc--275--C
    C-CountingSquares//会重复,所以要除4#include<bits/stdc++.h>usingnamespacestd;chars[10][10];boolcheck(intx,inty){returnx>=1&&y>=1&&x<=9&&y<......
  • [ABC264F] Monochromatic Path
    ProblemStatementWehaveagridwith$H$rowsand$W$columns.Eachsquareispaintedeitherwhiteorblack.Foreachintegerpair$(i,j)$suchthat$1\leq......
  • [ABC264Ex] Perfect Binary Tree
    ProblemStatementWehavearootedtreewith$N$verticesnumbered$1,2,\dots,N$.ThetreeisrootedatVertex$1$,andtheparentofVertex$i\ge2$isVerte......
  • [ABC264G] String Fair
    ProblemStatementInastringfair,theydeterminethebeautyofanon-emptystring$S$consistingoflowercaseEnglishletters.Thebeautyofstring$S$equal......