Codeforces Round #721 (Div. 2)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int fan(int n){
    for(ll i=n-1;i>=0;i--){
        n&=i;
        if(n==0){
            return i;
        }
    }
}
inline int uu(int n){
    ll ans=0;
    for(ll i=n;i>=0;i--){
        ans|=1<<i;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        for(int i=32;i>=0;i--){
            if(n>>i&1){
                cout<<int(pow(2,i)-1)<<"\n";
                break;
            }
        }
    }
}
A题

 

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        int n;string s;
        cin>>n>>s;
        int zeros=0;
        for(char c:s)
            if(c=='0')zeros++;
        if(zeros>1&&n%2==1&&s[n/2]=='0'){
            cout<<"ALICE\n";
        }
        else{
            cout<<"BOB\n";
        }
    }
}
B1题

 

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        map<int, vector<int>>v;
        int n;cin>>n;
        for(int i=0,x; i<n; i++)
        {
            cin>>x;
            v[x].push_back(i);
        }
        using ll = int64_t;
        ll ans=0;
        for(auto a:v)
        {
            ll pf=0;
            for(int x:a.second)
            {
                ans+=pf*(n-x);
                pf+=x+1;
            }
        }
        cout<<ans<<"\n";
    }
}
C题

 

posted @ 2021-05-21 00:46  Acception  阅读(34)  评论(0)    收藏  举报