CYHMMZDAN

1.1万

NIMBUS

hafu
currylin

An气质女孩

......_519
52Hertz_99
yxcの小迷弟

ZhengCheng
EramaanViimeinen
Asirzp
acwing_7358

CYHMMZDAN
13小时前


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();
for(int i=1;i<=n;i++) {
l=sc.nextInt();
f[l]++;
max=Math.max(max,l);
min=Math.min(min,l);
}
if(min==max){
System.out.println(ans);
}
else{
for(int i=200003;i>min;i--) {
f[i]+=f[i+1];
if(sum+f[i]>m) {
ans++;
sum=f[i];
}
else{
sum+=f[i];
}
}
System.out.println(sum>0?ans+1:ans);
}
}
}



CYHMMZDAN
14小时前
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();
for(int i=1;i<=n;i++) {
l=sc.nextInt();
max=Math.max(max,l);
}
System.out.println(l^max);

}
}




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);
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;
}
}

}
}