头像

CYHMMZDAN




离线:13小时前


最近来访(68)
用户头像
给梁梁买小狗
用户头像
宇宙有边
用户头像
槑头槑脑
用户头像
NIMBUS
用户头像
刻在DNA
用户头像
hafu
用户头像
currylin
用户头像
买了个锤子
用户头像
算法是什么牛马
用户头像
清煜
用户头像
An气质女孩
用户头像
吃饱了就不饿
用户头像
......_519
用户头像
52Hertz_99
用户头像
yxcの小迷弟
用户头像
举办龙泽谢谢喵
用户头像
ZhengCheng
用户头像
EramaanViimeinen
用户头像
Asirzp
用户头像
acwing_7358







import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
static long[] a=new long[1000005];
static long[] b=new long[1000005];
static int[] c=new int[200005];
static int[] d=new int[500005];
static int[] e=new int[200005];
static int[] f=new int[200005];
static int t=520;
static int ans=0;
static int max=-1;
static int min=(int)2e+9;
static int n=0;
static int m=0;
static int sum=0;
static int l=0;
static int r=0;

static HashMap<Integer,Integer> map=new HashMap<>();
public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    n=sc.nextInt();
    m=sc.nextInt();
    long l=m;
    long r=0;
    long sum=0;
    long max=0;
    long min=1000000005;
    for(int i=1;i<=n;i++) {
        sum+=sc.nextInt();
        if(sum>=0) {
            if(sum>=max) {
               l=m-sum;
               max=sum;
            }
        }
        else {
            if(sum<min) {
                   r=sum;
                   min=sum;
                }
        }
    }
    r=Math.abs(r);
    if(l>=r) {
        System.out.println(l-r+1);
    }
    else {
        System.out.println(0);
    }
}
}



题目讨论 AcWing 3992. ...






import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
static long[] a=new long[1000005];
static long[] b=new long[1000005];
static int[] c=new int[200005];
static int[] d=new int[500005];
static int[] e=new int[200005];
static int[] f=new int[200005];
static int t=520;
static int ans=0;
static int max=-1;
static int min=(int)2e+9;
static int n=0;
static int m=0;
static int sum=0;
static int l=0;
static int r=0;

static HashMap<Integer,Integer> map=new HashMap<>();
public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    n=sc.nextInt();
    m=sc.nextInt();
    long l=m;
    long r=0;
    long sum=0;
    long max=0;
    long min=1000000005;
    for(int i=1;i<=n;i++) {
        sum+=sc.nextInt();
        if(sum>=0) {
            if(sum>=max) {
               l=m-sum;
               max=sum;
            }
        }
        else {
            if(sum<min) {
                   r=sum;
                   min=sum;
                }
        }
    }
    r=Math.abs(r);
    if(l>=r) {
        System.out.println(l-r+1);
    }
    else {
        System.out.println(0);
    }
}
}









import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    static long[] a=new long[1000005];
    static long[] b=new long[1000005];
    static int[] c=new int[200005];
    static int[] d=new int[500005];
    static int[] e=new int[200005];
    static int[] f=new int[200005];
    static int t=520;
    static int ans=0;
    static int max=-1;
    static int min=(int)2e+9;
    static int n=0;
    static int m=0;
    static int sum=0;
    static int l=0;
    static int r=0;

    static HashMap<Integer,Integer> map=new HashMap<>();
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        if(s.charAt(0)=='1'&&s.length()==1){
            System.out.println(ans);
            System.exit(0);
        }
        StringBuilder s1=new StringBuilder();
        t=s.length()-1;
        while(t>=0&&s.charAt(t)!='1') {
            t--;
        }
        l=t;
        ans=s.length()-t-1;
        if(t==0){
            System.out.println(ans);
            System.exit(0);
        }
        s1.append(s.substring(0,t+1));
        while(true) {
            if(s1.length()==1) {
                break;
            }
            r=s1.length()-1;
            while(s1.charAt(l)!='0') {
                if(l==0){
                    break;
                }
                l--;
            }
            ans+=(1+(r-l));
            if(l==0){
                break;
            }

            s1.delete(l,r+1);
            s1.append('1');
            if(s1.length()==1) {
                break;
            }
        }
        System.out.println(ans+1);
    }
}









import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    static long[] a=new long[1000005];
    static long[] b=new long[1000005];
    static int[] c=new int[200005];
    static int[] d=new int[500005];
    static int[] e=new int[200005];
    static int[] f=new int[200005];
    static int t=520;
    static int ans=0;
    static int max=-1;
    static int min=(int)2e+9;
    static int n=0;
    static int m=0;
    static int sum=0;
    static int l=0;
    static int r=0;

    static HashMap<Integer,Integer> map=new HashMap<>();
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        if(s.charAt(0)=='1'&&s.length()==1){
            System.out.println(ans);
            System.exit(0);
        }
        StringBuilder s1=new StringBuilder();
        t=s.length()-1;
        while(t>=0&&s.charAt(t)!='1') {
            t--;
        }
        l=t;
        ans=s.length()-t-1;
        if(t==0){
            System.out.println(ans);
            System.exit(0);
        }
        s1.append(s.substring(0,t+1));
        while(true) {
            if(s1.length()==1) {
                break;
            }
            r=s1.length()-1;
            while(s1.charAt(l)!='0') {
                if(l==0){
                    break;
                }
                l--;
            }
            ans+=(1+(r-l));
            if(l==0){
                break;
            }

            s1.delete(l,r+1);
            s1.append('1');
            if(s1.length()==1) {
                break;
            }
        }
        System.out.println(ans+1);
    }
}









import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
static long[] a=new long[1000005];
static long[] b=new long[1000005];
static int[] c=new int[200005];
static int[] d=new int[500005];
static int[] e=new int[200005];
static int[] f=new int[200005];
static int t=520;
static int ans=0;
static int max=-1;
static int min=(int)2e+9;
static int n=0;
static int m=0;
static int sum=0;
static int l=0;
static int r=0;

static HashMap<Integer,Integer> map=new HashMap<>();
public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    while(n-->0) {
        l=sc.nextInt();
        r=sc.nextInt();
        ans=0;
        for(int i=1;i<=32;i++) {
            if(Math.pow(l,i)==r) {
                ans=520;
                break;
            }
        }
        if(ans==520) {
        System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }
}
}









import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
static long[] a=new long[1000005];
static long[] b=new long[1000005];
static int[] c=new int[200005];
static int[] d=new int[500005];
static int[] e=new int[200005];
static int[] f=new int[200005];
static int t=520;
static int ans=0;
static int max=-1;
static int min=(int)2e+9;
static int n=0;
static int m=0;
static int sum=0;
static int l=0;
static int r=0;

static HashMap<Integer,Integer> map=new HashMap<>();
public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    while(n-->0) {
        l=sc.nextInt();
        r=sc.nextInt();
        ans=0;
        for(int i=1;i<=l;i++) {
            if(r/i<=l&&r%i==0) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}
}









import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
static long[] a=new long[1000005];
static long[] b=new long[1000005];
static int[] c=new int[200005];
static int[] d=new int[500005];
static int[] e=new int[200005];
static int[] f=new int[200005];
static int t=520;
static int ans=0;
static int max=-1;
static int min=(int)2e+9;
static int n=0;
static int m=0;
static int sum=0;
static int l=0;
static int r=0;

static HashMap<Integer,Integer> map=new HashMap<>();
public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    while(n-->0) {
        String s=sc.next();
        ans=0;
        for(int i=0;i<s.length();i++) {
            if(s.charAt(i)=='1') {
                ans++;
                System.out.print(s.charAt(i));
            }
            else {
                ans=0;
                System.out.print(s.charAt(i));
            }
            if (ans==5) {
                i++;
                ans=0;
            }
        }
            System.out.println();

    }
}
}









import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
static long[] a=new long[1000005];
static long[] b=new long[1000005];
static int[] c=new int[200005];
static int[] d=new int[500005];
static int[] e=new int[200005];
static int[] f=new int[200005];
static int t=520;
static int ans=0;
static int max=-1;
static int min=(int)2e+9;
static int n=0;
static int m=0;
static int sum=0;
static int l=0;
static int r=0;

static HashMap<Integer,Integer> map=new HashMap<>();
public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    for(int i=n;i<=1314;i++) {
        sum=0;
        ans=i;
        while(ans!=0) {
            sum+=(ans%10);
            ans/=10;
        }
        if (sum%4==0) {
            System.out.println(i);
            break;
        }
    }

}
}





import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
static long[] a=new long[1000005];
static long[] b=new long[1000005];
static int[] c=new int[200005];
static int[] d=new int[200005];
static int[] e=new int[200005];
static int[] f=new int[200005];
static int t=520;
static int ans=0;
static int max=-1;
static int min=(int)2e+9;
static int n=0;
static int m=0;
static int sum=0;

static HashMap<Integer,Integer> map=new HashMap<>();
public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);

    for(int i=1;i<=4;i++) {
        d[i]=sc.nextInt();
    }
    String s=sc.next();
    for(int i=0;i<s.length();i++) {
        e[s.charAt(i)-48]++;
    }
    for(int i=1;i<=4;i++) {
        sum+=(d[i]*e[i]);
    }
    System.out.println(sum);
}

}



package hjk;




import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
static long[] a=new long[1000005];
static long[] b=new long[1000005];
static int[] c=new int[200005];
static int[] d=new int[200005];
static int[] e=new int[200005];
static int[] f=new int[200005];
static int t=520;
static int ans=0;
static int max=-1;
static int min=(int)2e+9;
static int n=0;
static int m=0;

static HashMap<Integer,Integer> map=new HashMap<>();
public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    n=sc.nextInt();
    while(n-->0) {
        int x=sc.nextInt();
        int y=sc.nextInt();
        int l=sc.nextInt();
        int r=sc.nextInt();
        if((y-x)%(l+r)==0) {
            System.out.println((y-x)/(l+r));
        }
        else {
            System.out.println(-1);
        }
    }
}
}