首页 > 其他分享 >AtCoder Beginner Contest 296 ABCD

AtCoder Beginner Contest 296 ABCD

时间:2023-04-01 23:46:09浏览次数:49  
标签:ABCD AtCoder typedef const int LL cin MAXN 296

https://atcoder.jp/contests/abc296

A - Alternately

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=2e6+10,M=3023;
const LL mod=100000007;
const double PI=3.1415926535;
#define endl '\n'
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        bool flag=true;
        LL n;
        cin>>n;
        string s;
        cin>>s;
        for(int i=0;i<n;i++)
        {
            if(s[i]==s[i-1])
            {
                flag=false;
                break;
            }
        }
        if(flag==false) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    return 0;
}

B - Chessboard

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=2e6+10,M=3023;
const LL mod=100000007;
const double PI=3.1415926535;
#define endl '\n'
map<LL,char> c;
map<LL,LL> r;
char a[M][M];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        c[1]='a',c[2]='b',c[3]='c';
        c[4]='d',c[5]='e',c[6]='f';
        c[7]='g',c[8]='h';
        for(int i=8;i>=1;i--)
        {
            r[i]=(8-i+1);
        }
        for(int i=1;i<=8;i++)
        {
            for(int j=1;j<=8;j++)
            {
                cin>>a[i][j];
                if(a[i][j]=='*') cout<<c[j]<<r[i]<<endl;
            }
        }
    }
    return 0;
}

C - Gap Existence

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=2e6+10,M=3023;
const LL mod=100000007;
const double PI=3.1415926535;
#define endl '\n'
LL a[N],x;
map<LL,LL> mp;
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL n,x;
        cin>>n>>x;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            mp[a[i]]++;
        }
        bool flag=false;
        for(int i=1;i<=n;i++)
        {
            if(mp[x+a[i]]!=0)
            {
                flag=true;
                break;
            }
        }
        if(flag==false) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    return 0;
}

D - M<=ab

题目大意:

给定一个n和m,要求我们找出a*b>=m中最小的a*b,a和b都必须在1-n的范围内.

这题m的数据范围在1e12之内,说明x*y在le12之内,即x和y最大在1e6处。

因此可以用O(n)的时间复杂度暴力解决。
Sample Input 3  
100000 10000000000
Sample Output 3  
10000000000
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=2e6+10,M=3023;
const LL mod=100000007;
const double PI=3.1415926535;
#define endl '\n'
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL n,m;
        cin>>n>>m;
        LL flag=1e6;
        LL ans=MAXN;
        for(int i=1;i<=min(flag,n);i++)
        {
            LL x=(m+i-1)/i;//m的基础上加上i-1,避免取整时降低次数
            if(x<=n) ans=min(x*i,ans);//这一部分也在范围内,才可以进行比较
        }
        if(ans==MAXN) cout<<"-1"<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}

标签:ABCD,AtCoder,typedef,const,int,LL,cin,MAXN,296
From: https://www.cnblogs.com/Vivian-0918/p/17279701.html

相关文章

  • AtCoder Beginner Contest 152
    AtCoderBeginnerContest152https://atcoder.jp/contests/abc152F我看了半天,编码方式那里还算是感觉比较玄乎,这题确实妙。D-Handstand2只需记录两端数字即可,不要想太复杂。#include<bits/stdc++.h>#definelllonglongusingnamespacestd;lln,sum,a[10][10];......
  • Codeforces Round 859 (Div. 4) ABCDE(交互题)FG1G2
    EFG1G2质量还挺好的A.PlusorMinushttps://codeforces.com/contest/1807/problem/A题目大意:给定a,b,c,问我们是a+b==c还是a-b==c?把正确的符号输出。input1112332129-7347112110336991899019-81910output+--++-++--+......
  • AtCoder Beginner Contest 295
    题解报告基本的一些理解和问题都在注释中A:ProbablyEnglish//水题#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>#include<string>#include<unordered_map>usingnamespacestd;constintmaxn=1e3+10;strings[......
  • 牛客小白月赛59 ABCDEF
    CEF题目质量挺高的https://ac.nowcoder.com/acm/contest/43844/AA-我会开摆#include<bits/stdc++.h>usingnamespacestd;typedeflonglongLL;typedefpair<LL,LL>PII;constLLMAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;constLLN=2e6+10,M=3023;constLLmod=1......
  • AtCoder Beginner Contest 246
    AtCoderBeginnerContest246A(思维)A这个题大意是告诉你一个矩形的三个点,求第四个点,并且已知每条边都是平行于\(x\)轴或者是\(y\)轴的,那么我们可以确定,\(x\)坐标只有两......
  • AtCoder Beginner Contest 295
    A-ProbablyEnglish#include<bits/stdc++.h>usingnamespacestd;intread(){intx=0,f=1,ch=getchar();while((ch<'0'||ch>'9')&&ch......
  • AtCoder Beginner Contest 145
    AtCoderBeginnerContest145https://atcoder.jp/contests/abc145D-Knight乍一看以为是dp,但是数据范围不允许。仔细一看发现,两种操作的次数是固定的,可以枚举出来每......
  • AtCoder Beginner Contest 148
    AtCoderBeginnerContest148https://atcoder.jp/contests/abc148这场比较简单D-BrickBreak二分orLIS#include<bits/stdc++.h>#definelllonglongusingn......
  • 【题解】Atcoder ABC295 A-G
    A.ProbablyEnglish题目分析:直接每一个单词判一下就好了。代码:点击查看代码#include<bits/stdc++.h>usingnamespacestd;intmain(){ intn;scanf("%d",&n); bo......
  • AtCoder Beginner Contest 248 F(连通性状压dp)
    F连通性状压dp思路看了dls的讲解后才明白一点点。状态\(dp[i][j][k]\)表示到表示到i列,删除了j条边,点i和n-1+i是否联通,对于下一列点,若当前i和n-1+i连通,则多出来的三条......