其实很简单

P1001 A+B Problem

鹿艺昂 @ 2019-10-02 11:08:46

incldue<iostream>

using namesapce std; int main() { int a,b,c; cin>>a>>b; c=a+b; cout<<c; return 0;//wonderful }


by d3ac @ 2019-10-06 17:29:01

#include<cstdio>
#include<algorithm>
#include<cstring>
#define maxn 500000
using namespace std;
int T,len;
char s[maxn];
bool check(int k){
    int lpos=0,cnt=k-1,nowlen=k;
    for(int i=1;i<=len;i++){
        /*lpos++;
        if(!cnt && nowlen==lpos){
            cnt=k-1; nowlen=i-1;
            lpos=0; continue;
        }
        if(lpos==nowlen) {lpos=0; cnt--; continue;}
        if(s[lpos]!=s[i]) return false;*/
        lpos++;
        if(!cnt && nowlen==lpos)//nowlen为指向谁就不行
        {
//          printf("%d %d\n",nowlen,lpos);
            cnt=k-2; nowlen=i;
            lpos=0; continue;
        } 
        if(lpos==nowlen) {lpos=0; cnt--; continue;}
        if(s[lpos]!=s[i]) return false;
    }
    return true;
}
int main()
{
//  freopen("data.in","r",stdin);
    scanf("%d",&T);
    while(T--){
        scanf("%s",s+1);
        len=strlen(s+1);
        int ans=2;
        for(int ax=2;ax<=len;ax++){
            if(check(ax)){
                ans=ax;
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

by L______ @ 2019-10-06 17:29:26

#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x7f7f7f7f
#define N 1000010
using namespace std;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int n,m,a[N];
bool book[N];

int main(){
    n=read(),m=read();
    for(int i=1;i<=n;i++){
        a[i]=read();
    }
    while(m--){
        int l=read(),r=read(),x=read();
        int maxx=-inf,minn=inf;
        memset(book,0,sizeof(book));
        for(int i=l;i<=r;i++){
            maxx=max(maxx,a[i]);
            minn=min(minn,a[i]);
            book[a[i]]=1;
        }
        int cnt=0;
        for(int i=max(0,minn-x);i<=maxx;i++){
            int j=i+x;
            if(book[i]==1 || book[j]==1) continue;          if(book[i]==1) continue;
            if(book[j]==1) continue;
            int flag=0;
            for(int k=i+10;k<=j-1;k++){
                if(book[k]==1){
                    flag=1;
                    break;
                }               }

        printf("%d\n",cnt); if(flag!=1) cnt++;

    return 0;       }
        }
    }
}

by Modest_ @ 2019-10-06 17:29:33

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
/*namespace fastIO
{ 
    #define BUF_SIZE 100000
    #define OUT_SIZE 100000
    #define ll long long
    bool IOerror=0;
    inline char nc()
    {
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if(p1==pend)
        {
            p1=buf;
            pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if(pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x)
    {
        bool sign=0;
        char ch=nc();
        x=0;
        for(;blank(ch);ch=nc());
        if(IOerror)return;
        if(ch=='-')sign=1,ch=nc();
        for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if(sign)x=-x;
    }
    inline void read(ll &x)
    {
        bool sign=0;
        char ch=nc();
        x=0;
        for(;blank(ch);ch=nc());
        if(IOerror)return;
        if(ch=='-')sign=1,ch=nc();
        for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if(sign)x=-x;
    }
    char ss[1000000*15],tt[20];
    int ssl,ttl;
    inline int Flush()
    {
        fwrite(ss+1,sizeof(char),ssl,stdout);
        ssl=0;
        return 0;
    }
    inline int print(int x)
    {
        if(!x)ss[++ssl]='0';
        if(x<0)ss[++ssl]='-',x=-x;
        for(ttl=0;x;x/=10)tt[++ttl]=char(x%10+'0');
        for(;ttl;ttl--)ss[++ssl]=tt[ttl];
        return ss[++ssl]='\n';
    }
    inline int print(ll x)
    {
        if(!x)ss[++ssl]='0';
        if(x<0)ss[++ssl]='-',x=-x;
        for(ttl=0;x;x/=10)tt[++ttl]=char(x%10+'0');
        for(;ttl;ttl--)ss[++ssl]=tt[ttl];
        return ss[++ssl]='\n';
    }
    #undef OUT_SIZE
    #undef BUF_SIZE
};
using namespace fastIO;*/
#define ll long long
const int maxn=301010;
const int inf=0x7f7f7f7f;
int n,m,a[maxn],book[maxn],b[maxn];

int main()
{
    //read(n);read(m);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        //read(m);
        scanf("%d",&a[i]);
    }
    while(m--)
    {
        int l,r,c;
        //read(l);read(r);read(c);
        scanf("%d%d%d",&l,&r,&c);
        for(int i=l;i<=r;i++)
        {
            b[i]=a[i];
        }
        sort(b+l,b+r+1);
        b[r+1]=inf;
        int tot=0;
        int st=b[l];
        for(int i=l+1;i<=r+1;i++)
        {
            if(b[i]>b[i-1]+1)
            {
                if(b[i-1]-st+2==c)
                {
                    tot++;
                }
                st=b[i];
            }
        }
        printf("%d\n",tot);
    }
    return 0;
}

by _Felix @ 2019-10-17 14:04:20

JFCA


by bunH2O @ 2019-10-26 21:28:42

大家注意一下楼主发的代码:#incldue<iostream>


by smy2006 @ 2019-11-29 20:27:45

%%% orzorz


by GBWANG7786 @ 2022-09-10 10:11:53

@鹿艺昂 %%%


上一页 |