henrychenOutlook

3173

Egbert-Lannister.

shaonianxiaozeng
2144141603@qq.com

cony
qjtbdh288

auraro1
Feelme
Nefelibata_6

songpy

L_722
Ker

https://codeforces.com/contest/1747/problem/C

import java.util.*;
import java.io.*;

class Main {
static PrintWriter pw;

void solve(int n, int[] a) {
int min = Arrays.stream(a).min().getAsInt();
pr(a[0] == min ? "Bob" : "Alice");
}

private void run() {
// read_write_file(); // comment this before submission
FastScanner fs = new FastScanner();
int t = fs.nextInt();
while (t-- > 0) {
int n = fs.nextInt();
solve(n, a);
}
}

private final String INPUT = "input.txt";
private final String OUTPUT = "output.txt";

FileInputStream instream = null;
PrintStream outstream = null;
try {
instream = new FileInputStream(INPUT);
outstream = new PrintStream(new FileOutputStream(OUTPUT));
System.setIn(instream);
System.setOut(outstream);
} catch (Exception e) {
}
}

public static void main(String[] args) {
pw = new PrintWriter(System.out);
new Main().run();
pw.close();
}

<T> void pr(T t) {
pw.println(t);
}

class FastScanner {
StringTokenizer st = new StringTokenizer("");

String next() {
while (!st.hasMoreTokens())
try {
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}

int nextInt() {
return Integer.parseInt(next());
}

int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
}

void tr(Object... o) {
pw.println(Arrays.deepToString(o));
}
}


import java.util.*;
import java.io.*;

class Main {
static PrintWriter pw;

void solve(int n, long[] a) {
for (long x : a) {
int sq = (int) Math.sqrt(x);
if ((long) sq * sq != x) {
pr("NO");
continue;
}
pr(isPrime(sq) ? "YES" : "NO");
}
}

boolean isPrime(int n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i += 6) {
if (n % i == 0 || n % (i + 2) == 0) return false;
}
return true;
}

private void run() {
// read_write_file(); // comment this before submission
FastScanner fs = new FastScanner();
int n = fs.nextInt();
solve(n, a);
}

private final String INPUT = "input.txt";
private final String OUTPUT = "output.txt";

FileInputStream instream = null;
PrintStream outstream = null;
try {
instream = new FileInputStream(INPUT);
outstream = new PrintStream(new FileOutputStream(OUTPUT));
System.setIn(instream);
System.setOut(outstream);
} catch (Exception e) {
}
}

public static void main(String[] args) {
pw = new PrintWriter(System.out);
new Main().run();
pw.close();
}

<T> void pr(T t) {
pw.println(t);
}

class FastScanner {
StringTokenizer st = new StringTokenizer("");

String next() {
while (!st.hasMoreTokens())
try {
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}

int nextInt() {
return Integer.parseInt(next());
}

long[] a = new long[n];
for (int i = 0; i < n; i++) a[i] = nextLong();
return a;
}

long nextLong() {
return Long.parseLong(next());
}
}

void tr(Object... o) {
pw.println(Arrays.deepToString(o));
}
}


import java.util.*;
import java.io.*;

class Main {
static PrintWriter pw;

private void run() {
// read_write_file(); // comment this before submission
FastScanner fs = new FastScanner();
int n = fs.nextInt();
double res = (double) n / 5;
pr((int) Math.ceil(res));
}

private final String INPUT = "input.txt";
private final String OUTPUT = "output.txt";

FileInputStream instream = null;
PrintStream outstream = null;
try {
instream = new FileInputStream(INPUT);
outstream = new PrintStream(new FileOutputStream(OUTPUT));
System.setIn(instream);
System.setOut(outstream);
} catch (Exception e) {
}
}

public static void main(String[] args) {
pw = new PrintWriter(System.out);
new Main().run();
pw.close();
}

<T> void pr(T t) {
pw.println(t);
}

class FastScanner {
StringTokenizer st = new StringTokenizer("");

String next() {
while (!st.hasMoreTokens())
try {
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}

int nextInt() {
return Integer.parseInt(next());
}

int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
}

void tr(Object... o) {
pw.println(Arrays.deepToString(o));
}
}


import java.util.*;
import java.io.*;

class Main {
static PrintWriter pw;
Map<String, Integer> costM;

void solve(int n, int m, int[][] edges, Set[] forbid) {
List<List<Integer>> g = initializeGraph(n + 1);
costM = new HashMap<>();
packUGCost(g, edges);
long[] dis = new long[n + 1];
Arrays.fill(dis, Long.MAX_VALUE);
Deque<long[]> q = new ArrayDeque<>();
dis[1] = 0L;
while (!q.isEmpty()) {
long[] tmp = q.poll();
int cur = (int) tmp[0];
long t = dis[cur];
Set<Long> se = forbid[cur];
while (se.contains(t)) {
t++;
}
for (int child : g.get(cur)) {
int cost = costM.get(cur + " " + child);
if (dis[child] > t + cost) {
dis[child] = t + cost;
}
}
}
pr(dis[n] == Long.MAX_VALUE ? -1 : dis[n]);
}

List<List<Integer>> initializeGraph(int n) {
List<List<Integer>> g = new ArrayList<>();
for (int i = 0; i < n; i++) {
}
return g;
}

void packUGCost(List<List<Integer>> g, int[][] edges) {
for (int[] a : edges) {
costM.put(a[0] + " " + a[1], a[2]);
costM.put(a[1] + " " + a[0], a[2]);
}
}

private void run() throws IOException {
// read_write_file(); // comment this before submission
FastScanner fs = new FastScanner();
int n = fs.nextInt(), m = fs.nextInt();
int[][] edges = new int[m][];
for (int i = 0; i < m; i++) edges[i] = fs.readArray(3);
Set[] forbid = new Set[n + 1];
for (int i = 0; i < n; i++) {
String[] a = fs.nextLine().split(" ");
forbid[i + 1] = new HashSet();
//            for (String c : a) {
//            }
for (int j = 1; j < a.length; j++) {
}
}
solve(n, m, edges, forbid);
}

private final String INPUT = "input.txt";
private final String OUTPUT = "output.txt";

FileInputStream instream = null;
PrintStream outstream = null;
try {
instream = new FileInputStream(INPUT);
outstream = new PrintStream(new FileOutputStream(OUTPUT));
System.setIn(instream);
System.setOut(outstream);
} catch (Exception e) {
}
}

public static void main(String[] args) throws IOException {
pw = new PrintWriter(System.out);
new Main().run();
pw.close();
}

<T> void pr(T t) {
pw.println(t);
}

class FastScanner {
StringTokenizer st = new StringTokenizer("");

String next() {
while (!st.hasMoreTokens())
try {
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}

int nextInt() {
return Integer.parseInt(next());
}

int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}

String nextLine() throws IOException {
}
}

void tr(Object... o) {
pw.println(Arrays.deepToString(o));
}
}


import java.util.*;
import java.io.*;

class Main {
static PrintWriter pw;

private void run() {
// read_write_file(); // comment this before submission
FastScanner fs = new FastScanner();
int n = fs.nextInt();
long[] preA = preSum(a);
Arrays.sort(a);
long[] preB = preSum(a);
int m = fs.nextInt();
for (int i = 0; i < m; i++) {
long res;
if (e[0] == 1) {
res = subArraySum(preA, e[1] - 1, e[2] - 1);
} else {
res = subArraySum(preB, e[1] - 1, e[2] - 1);
}
pr(res);
}
}

long[] preSum(int[] a) {
int n = a.length;
long[] pre = new long[n + 1];
for (int i = 0; i < n; i++) pre[i + 1] = pre[i] + a[i];
return pre;
}

long subArraySum(long[] a, int l, int r) {
return a[r + 1] - a[l];
}

private final String INPUT = "input.txt";
private final String OUTPUT = "output.txt";

FileInputStream instream = null;
PrintStream outstream = null;
try {
instream = new FileInputStream(INPUT);
outstream = new PrintStream(new FileOutputStream(OUTPUT));
System.setIn(instream);
System.setOut(outstream);
} catch (Exception e) {
}
}

public static void main(String[] args) {
pw = new PrintWriter(System.out);
new Main().run();
pw.close();
}

<T> void pr(T t) {
pw.println(t);
}

class FastScanner {
StringTokenizer st = new StringTokenizer("");

String next() {
while (!st.hasMoreTokens())
try {
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}

int nextInt() {
return Integer.parseInt(next());
}

int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
}

void tr(Object... o) {
pw.println(Arrays.deepToString(o));
}
}


import java.util.*;
import java.io.*;

class Main {
static PrintWriter pw;

void solve(int n, int[][] a) {
Map<String, Integer> m = counter(a);
int res = 1;
for (int occ : m.values()) res = Math.max(res, occ);
pr(res);
}

Map<String, Integer> counter(int[][] a) {
Map<String, Integer> m = new HashMap<>();
for (int[] e : a) {
String ke = e[0] + " " + e[1];
m.put(ke, m.getOrDefault(ke, 0) + 1);
}
return m;
}

private void run() {
// read_write_file(); // comment this before submission
FastScanner fs = new FastScanner();
int n = fs.nextInt();
int[][] a = new int[n][];
for (int i = 0; i < n; i++) a[i] = fs.readArray(2);
solve(n, a);
}

private final String INPUT = "input.txt";
private final String OUTPUT = "output.txt";

FileInputStream instream = null;
PrintStream outstream = null;
try {
instream = new FileInputStream(INPUT);
outstream = new PrintStream(new FileOutputStream(OUTPUT));
System.setIn(instream);
System.setOut(outstream);
} catch (Exception e) {
}
}

public static void main(String[] args) {
pw = new PrintWriter(System.out);
new Main().run();
pw.close();
}

<T> void pr(T t) {
pw.println(t);
}

class FastScanner {
StringTokenizer st = new StringTokenizer("");

String next() {
while (!st.hasMoreTokens())
try {
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}

int nextInt() {
return Integer.parseInt(next());
}

int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
}

void tr(Object... o) {
pw.println(Arrays.deepToString(o));
}
}


codeforce 提交结果 https://codeforces.com/problemset/submission/96/171187474

import java.util.*;
import java.io.*;

public class Main {
static PrintWriter pw;

void solve(int n) {
TreeSet<Long> ts = buildSuperLuckyNumber();
for (long x : ts) {
if (x >= n) {
pr(x);
return;
}
}
}

TreeSet<Long> buildSuperLuckyNumber() {
TreeSet<Long> res = new TreeSet<>();
Deque<Character> cur = new ArrayDeque<>();
dfs(cur, res);
return res;
}

void dfs(Deque<Character> cur, TreeSet<Long> res) {
if (cur.size() > 11) return; // max 7777744444
for (char i = '0'; i <= '9'; i++) {
if (ok(cur)) {
dfs(cur, res);
}
cur.pollLast();
}
}

boolean ok(Deque<Character> q) {
if (q.size() > 11) return false;
for (char c : q) {
if (c != '4' && c != '7') return false;
}
return true;
}

long appendNumber(Deque<Character> q) {
String s = "";
for (char c : q) s += c;
return Long.parseLong(s);
}

boolean isEqual(Deque<Character> cur) {
int four = 0, seven = 0;
for (int x : cur) {
if (x == '4') {
four++;
} else {
seven++;
}
}
return four == seven;
}

private void run() {
// read_write_file(); // comment this before submission
FastScanner fs = new FastScanner();
int n = fs.nextInt();
solve(n);
}

private final String INPUT = "input.txt";
private final String OUTPUT = "output.txt";

FileInputStream instream = null;
PrintStream outstream = null;
try {
instream = new FileInputStream(INPUT);
outstream = new PrintStream(new FileOutputStream(OUTPUT));
System.setIn(instream);
System.setOut(outstream);
} catch (Exception e) {
}
}

public static void main(String[] args) {
pw = new PrintWriter(System.out);
new Main().run();
pw.close();
}

<T> void pr(T t) {
pw.println(t);
}

class FastScanner {
StringTokenizer st = new StringTokenizer("");

String next() {
while (!st.hasMoreTokens())
try {
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}

int nextInt() {
return Integer.parseInt(next());
}

int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
}

void tr(Object... o) {
pw.println(Arrays.deepToString(o));
}
}



1 -> [1, 5]
2 -> [6, 15]
4 -> [16, 35]
8 -> [36, 75]
16 -> [76, 155]
......

import java.util.*;
import java.io.*;

class Main {
static PrintWriter pw;

void solve(int n) {
if (n == 1) {
pr('a');
return;
}
char[] a = {'a', 'b', 'c', 'd', 'e'};
int l = 1;
for (int i = 0; 1 << i < n; i++) {
int v = 1 << i, line = v * 5; // v 表示1 2 4 8 16...  line 表示当前层的总数
int r = l + line - 1;
int[] range = new int[]{l, r}; // 当前层的range  [1, 5], [6, 15]....
if (n >= l && n <= r) { // n 在当前层, 计算结果
double d = (double) (n - l + 1) / v;
int idx = (int) Math.ceil(d);
pr(a[idx - 1]);
break;
}
l = r + 1;
}
}

/*
1 a b c d e
2 aa bb cc dd ee
4 aaaa bbbb cccc dddd eeee
8 aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee
*/
void test(int n) {
Deque<Character> q = new ArrayDeque<>();
int cnt = 0;
while (true) {
char x = q.poll();
tr(x);
cnt++;
if (cnt == n) {
pr(x);
break;
}
}
}

private void run() {
// read_write_file(); // comment this before submission
FastScanner fs = new FastScanner();
int n = fs.nextInt();
solve(n);
}

private final String INPUT = "input.txt";
private final String OUTPUT = "output.txt";

FileInputStream instream = null;
PrintStream outstream = null;
try {
instream = new FileInputStream(INPUT);
outstream = new PrintStream(new FileOutputStream(OUTPUT));
System.setIn(instream);
System.setOut(outstream);
} catch (Exception e) {
}
}

public static void main(String[] args) {
pw = new PrintWriter(System.out);
new Main().run();
pw.close();
}

<T> void pr(T t) {
pw.println(t);
}

class FastScanner {
StringTokenizer st = new StringTokenizer("");

String next() {
while (!st.hasMoreTokens())
try {
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}

int nextInt() {
return Integer.parseInt(next());
}

int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
}

void tr(Object... o) {
pw.println(Arrays.deepToString(o));
}
}


import java.util.*;
import java.io.*;

class Main {
static PrintWriter pw;

void solve(int n, char[] s) {
int[] a = new int[n];
Arrays.fill(a, 1);
for (int i = 0; i < s.length; i++) {
if (s[i] == '>') {
} else if (s[i] == '<') {
a[i + 1] = a[i] + 1;
} else {
a[i + 1] = a[i];
}
}
for (int i = n - 2; i >= 0; --i) {
if (s[i] == '>') {
a[i] = Math.max(a[i], a[i + 1] + 1);
} else if (s[i] == '<') {
} else {
a[i] = a[i + 1];
}
}
outputA(a);
}

void outputA(int[] a) {
for (int e : a) pw.print(e + " ");
pr("");
}

private void run() {
// read_write_file(); // comment this before submission
FastScanner fs = new FastScanner();
int n = fs.nextInt();
char[] s = fs.next().toCharArray();
solve(n, s);
}

private final String INPUT = "input.txt";
private final String OUTPUT = "output.txt";

FileInputStream instream = null;
PrintStream outstream = null;
try {
instream = new FileInputStream(INPUT);
outstream = new PrintStream(new FileOutputStream(OUTPUT));
System.setIn(instream);
System.setOut(outstream);
} catch (Exception e) {
}
}

public static void main(String[] args) {
pw = new PrintWriter(System.out);
new Main().run();
pw.close();
}

<T> void pr(T t) {
pw.println(t);
}

class FastScanner {
StringTokenizer st = new StringTokenizer("");

String next() {
while (!st.hasMoreTokens())
try {
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}

int nextInt() {
return Integer.parseInt(next());
}

int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
}

void tr(Object... o) {
pw.println(Arrays.deepToString(o));
}
}


import java.util.*;
import java.io.*;

class Main {
static PrintWriter pw;

private void run() {
// read_write_file(); // comment this before submission
FastScanner fs = new FastScanner();
String s = fs.next(), t = fs.next();
pr(reverse(s).equals(t) ? "YES" : "NO");
}

String reverse(String s) {
int n = s.length();
String res = "";
for (int i = n - 1; i >= 0; i--) res += s.charAt(i);
return res;
}

private final String INPUT = "input.txt";
private final String OUTPUT = "output.txt";

FileInputStream instream = null;
PrintStream outstream = null;
try {
instream = new FileInputStream(INPUT);
outstream = new PrintStream(new FileOutputStream(OUTPUT));
System.setIn(instream);
System.setOut(outstream);
} catch (Exception e) {
}
}

public static void main(String[] args) {
pw = new PrintWriter(System.out);
new Main().run();
pw.close();
}

<T> void pr(T t) {
pw.println(t);
}

class FastScanner {
StringTokenizer st = new StringTokenizer("");

String next() {
while (!st.hasMoreTokens())
try {
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}

int nextInt() {
return Integer.parseInt(next());
}