A

#include<bits/stdc++.h>
#define int long long
using namespace std;
struct ios {
    inline char read(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> inline ios & operator >> (_Tp&x){
        static char c11,boo;
        for(c11=read(),boo=0;!isdigit(c11);c11=read()){
            if(c11==-1)return *this;
            boo|=c11=='-';
        }
        for(x=0;isdigit(c11);c11=read())x=x*10+(c11^'0');
        boo&&(x=-x);
        return *this;
    }
} io;
int n,k;
int a[20000007];
int l=1,r=1,ans=-1,tot;
signed main()
{
    io>>n>>k;
    for(int i=1;i<=n;i++)    io>>a[i];
    while(r<=n){
        while(r<=n&&tot+a[r]<=k) tot+=a[r],r++;
        if(tot==k) ans=max(ans,r-l);
        tot-=a[l++];
    }
    cout<<ans<<"\n";
    return 0;
}

B

#include<bits/stdc++.h>
#define int long long
using namespace std;
int arr[11]={0,1,2,3,4,5,6,7,8,9};
int n,k,ans;
signed main()
{
    cin>>n>>k;
    do{
        int h=0;
        for(int i=0;i<n;i++)
            h=h*10+arr[i];
        if(h%k==0) ans++;
    }while(next_permutation(arr,arr+n));
    if(ans==0) ans=-1;
    cout<<ans<<"\n";
    return 0;
}

C

#include<bits/stdc++.h>
using namespace std;
int n,m;
int h[1000006];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        h[i]=h[i-1]+x;
    }
    while(m--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        printf("%d\n",h[y]-h[x-1]);
    }
    return 0;
}

D

...懒得打了...

E

#include<bits/stdc++.h>
using namespace std;
char a[20000007];
int k,n,l=1,flag,tot;
int get(int l,int r)
{
    int MIN=1001,k;
    for(int i=l;i<=r&&MIN!='0';i++){
        if(a[i]<MIN){
            k=i;
            MIN=a[i];
        }
    }
    return k;
}
int main()
{
    scanf("%s",a+1); 
    n=strlen(a+1);
    cin>>k;
    if((double)clock()/CLOCKS_PER_SEC >0.5) return 0;
    if(n==k){
        puts("0");
        return 0;
    }
    for(int i=k+1;i<=n&&tot<n-k;i++){
        int k;
        if(l!=i) k=get(l,i);
        else    k=i;
        l=k+1;
        if(a[k]=='0'&&!flag) continue;
        flag=1;
        putchar(a[k]);
        tot++;
    }
    if(flag==0) cout<<"0";
    return 0;
}

F

#include<bits/stdc++.h>
using namespace std;
long long n;
int main()
{
    cin>>n;
    int k=log(n)/log(2)+1;
    cout<<(1ll<<k)-1<<"\n";
    return 0;
}

G

python打的

import re
n=int(input())
ans=0
for i in range(n):
    k=input()
    if len(re.findall('A[ ]*l[ ]*a[ ]*n', k)):
        ans+=len(re.findall('%',k))
print(ans)

H&I

#include<bits/stdc++.h>
using namespace std;
int n;
struct oppo{
    string s,m,x,h;
    int k;
}a[1000006];
bool cmp(oppo a,oppo b)
{
    if(a.s.length()!=b.s.length())
    return a.s.length()<b.s.length();
    if(a.s!=b.s)
    return a.s<b.s;
    return a.k<b.k;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].s>>a[i].m>>a[i].x>>a[i].h;
        a[i].k=i;
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++){
        cout<<a[i].s<<" "<<a[i].m<<" "<<a[i].x<<" "<<a[i].h<<"\n";
    }
    return 0;
}

J

#include<bits/stdc++.h>
using namespace std;
int n;
int MIN=INT_MAX,k;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        if(x<MIN){
            k=i;
            MIN=x;
        }
    }
    cout<<k<<"\n";
    return 0;
}