首页 > 其他分享 >The 2022 ICPC Asia Regionals Online Contest (II)

The 2022 ICPC Asia Regionals Online Contest (II)

时间:2022-11-09 20:03:08浏览次数:157  
标签:pre Contest int LL cin Asia ICPC fa lx

一直没补,把之前的粘贴过来

E An Interesting Sequence

 为使数组和小,并且gcd=1,我们添加2,3,,找到第一个不整除k的质数,然后后面放2,3,判断先放2还是3

J A Game about Increasing Sequences

Alice and Bob like playing games.

The game is played on a sequence of length n. Alice and Bob take turns performing the operation, with Alice going first.

In each operation, the player can remove an element from the beginning or the end of the sequence.

If this operation is not the first operation of the game, the removed element must be strictly greater than all the previously removed elements.

The player who cannot perform the operation loses.

Please determine who will win the game if both Alice and Bob play the game optimally.

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int a[N];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    int l=1;
    for(int i=2;i<=n;i++){
        if(a[i]>a[i-1])l++;
        else break;
    }
    int r=1;
    for(int i=n-1;i>=1;i--){
        if(a[i]>a[i+1])r++;
        else break;
    }
    if(l%2==0&&r%2==0)puts("Bob");
    else puts("Alice");
}

F Infinity Tree

#include<bits/stdc++.h> 
using namespace std;
typedef long long int LL;
vector<LL> xx,yy; 
void find1(LL x,LL k){
    LL d=k+1; LL idex=1; LL lx=1; LL pre; 
    for(int i=1;idex<=1e18/d;i++){ 
        pre=idex; idex*=d; 
        if(idex>=x){ 
            lx=pre; break;
        } 
        pre=idex;
    } 
    lx=pre; LL fa;
    if((x-lx)%k==0)fa=(x-lx)/k;
    else fa=(x-lx)/k+1; xx.push_back(fa); //cout<<fa<<endl; 
    if(fa==1)return ;
    else find1(fa,k);
}
void find2(LL x,LL k){
    LL d=k+1; LL idex=1;
    LL lx=1; LL pre; 
    for(int i=1;idex<=1e18/d;i++){ 
        pre=idex; 
        idex*=d; 
        if(idex>=x){ 
            lx=pre; break;
        } pre=idex;
    }
    lx=pre; LL fa; 
    if((x-lx)%k==0)fa=(x-lx)/k;
    else fa=(x-lx)/k+1;
    yy.push_back(fa); //cout<<fa<<endl;
    if(fa==1)return ; 
    else find2(fa,k); 
}
LL ans; 
void solve(){
    LL k,x,y;
    cin>>k>>x>>y;
    xx.clear();yy.clear();
    xx.push_back(x); 
    yy.push_back(y); 
    find1(x,k); 
    find2(y,k);
    for(int i=0;i<xx.size();i++){ 
        for(int j=0;j<yy.size();j++){ 
            if(xx[i]==yy[j]){
                ans=xx[i];
                return ; 
            }
        }
    }
}
int main(){ 
    int t;
    cin>>t; 
    while(t--){ 
        solve();
        cout<<ans<<endl;
    }
}

A Yet Another Remainder

#include<bits/stdc++.h>

using namespace std;
const int N=100+10;
int a[N][N];
int ph[N];
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        for(int i=1;i<=min(n,100);i++){
           for(int j=1;j<=i;j++){
             cin>>a[i][j];
           }
        }
        
        int q;
        cin>>q;
        while(q--){
            int p;
            cin>>p;
            ph[0]=1;
        for(int i=1;i<=100;i++){
            ph[i]=ph[i-1]*10%p;
        }
            int k=p-1;
            if(n<=100){
                long long res=0;
                for(int i=1;i<=n;i++){
                    res=(res*10+a[n][i])%p;
                }
                cout<<res<<endl;
            }
            else{
                long long ans=0;
                for(int i=1;i<=k;i++){
                    ans=(ans+a[k][i]*ph[(n-i)%k])%p;
                }
                cout<<ans<<endl;
            }
        }
    }
}

 B Non-decreasing Array

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 110;

int n,a[N];
int f[N][N];

signed main(){
    cin >> n;
    for(int i = 1; i <= n ; ++i)cin >>a[i];

    for(int i = 2; i <= n; ++i){
        for(int j = 2; j <= n;++j){
            for(int k = j - 1; k < i; ++k){
                f[i][j] = max(f[i][j],f[k][j - 1] + (a[i] - a[k])*(a[i] - a[k]));
            }
        }
    }

    int b = (a[n] - a[1])*(a[n] - a[1]);

    int cnt = 0;
    for(int i = n - 2; i >= 2; i -= 2){
        if(f[n][i] == b)break;
        cout<<f[n][i]<<endl;
        cnt ++ ;
    }
    for(int i = cnt; i < n; ++i)cout<<b<<endl;
    return 0;
}
 

标签:pre,Contest,int,LL,cin,Asia,ICPC,fa,lx
From: https://www.cnblogs.com/Dengpc/p/16874981.html

相关文章

  • The 2020 ICPC Asia Shenyang Regional Programming Contest
    VP题目列表D.JourneytoUn'GoroF.KoboldsandCatacombsG.TheWitchwoodH.TheBoomsdayProjectI.RiseofShadowsJ.DescentofDragonsK.S......
  • 2022ICPC区域赛参后感悟
    第一次参加正式的大类赛事,在某种程度上挺激动的。我呢,可以说是刚步入竞赛一年,在此期间遇见了一些志同道合的朋友,最重要的是遇见了我的队友。开始前,我幻想过我们小队可以超......
  • AtCoder Beginner Contest 275
    A-FindTakahashi找到序列中最高的数存在的位置#include<bits/stdc++.h>usingnamespacestd;intread(){intx=0,f=1,ch=getchar();while((c......
  • Atcoder Beginner Contest 276(A~G)
    赛时A简单字符串处理;B简单vector处理;C找上一个排列。D找到每一个数因子\(2\)的个数和\(3\)的个数,并判断除去这些因子之后剩下的值是否相同,若不同则不能满足条......
  • 第 45 届国际大学生程序设计竞赛(ICPC)亚洲区域赛(昆明)
    比赛链接:https://ac.nowcoder.com/acm/contest/12548/H.HardCalculation思路:输出\(x\)+2020。代码:#include<bits/stdc++.h>usingnamespacestd;usingLL=l......
  • AtCoder Beginner Contest 276
    A-Rightmost#include<bits/stdc++.h>usingnamespacestd;int32_tmain(){strings;cin>>s;for(inti=s.size();i>=1;i--)i......
  • [Leetcode Weekly Contest]318
    链接:LeetCode[Leetcode]2460.对数组执行操作给你一个下标从0开始的数组nums,数组大小为n,且由非负整数组成。你需要对数组执行n-1步操作,其中第i步操作(从0......
  • 45th ICPC昆明 C.Cities(区间dp)
    题目链接Description有n个点,每个点有自己的颜色(并且每种颜色出现次数不超过15次),每次操作可以把一段连续且颜色相同的点染成任意一种颜色,求把所有点染成相同颜色的最小操......
  • 第 45 届国际大学生程序设计竞赛(ICPC)亚洲区域赛(济南)
    比赛链接:https://ac.nowcoder.com/acm/contest/10662/C.StoneGame题意:有\(a1\)堆有1个石子的石堆,\(a2\)堆有两个石子的石堆,\(a3\)堆有三个石子的石堆。合并两......
  • ICPC2022沈阳站游记
    拿到了本校第一个区域赛银。本来目标只是拿铜的,因为这场队伍实在太多了,但没想到质量不是很高。赛前就决定要拼速度。开赛前看封面,DRXVST1,却没想到这是签到题。还好......