diff --git a/112/A.java b/112/A.java new file mode 100644 index 0000000..ee1387d --- /dev/null +++ b/112/A.java @@ -0,0 +1,119 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Random; +import java.util.StringTokenizer; + +public class A { + private FastScanner fs = new FastScanner(); + private PrintWriter out = new PrintWriter(System.out); + + void solve() { + String a = fs.next().toLowerCase(); + String b = fs.next().toLowerCase(); + out.println((int)Math.signum(a.compareTo(b))); + } + + void run() { + solve(); + out.close(); + } + + public static void main(String[] args) { + new A().run(); + } + + static final Random random = new Random(); + static final int mod = 1_000_000_007; + + static void ruffleSort(int[] a) { + int n = a.length;// shuffle, then sort + for (int i = 0; i < n; i++) { + int oi = random.nextInt(n), temp = a[oi]; + a[oi] = a[i]; + a[i] = temp; + } + Arrays.sort(a); + } + + static long add(long a, long b) { + return (a + b) % mod; + } + + static long sub(long a, long b) { + return ((a - b) % mod + mod) % mod; + } + + static long mul(long a, long b) { + return (a * b) % mod; + } + + static long exp(long base, long exp) { + if (exp == 0) + return 1; + long half = exp(base, exp / 2); + if (exp % 2 == 0) + return mul(half, half); + return mul(half, mul(half, base)); + } + + static long[] factorials = new long[2_000_001]; + static long[] invFactorials = new long[2_000_001]; + + static void precompFacts() { + factorials[0] = invFactorials[0] = 1; + for (int i = 1; i < factorials.length; i++) + factorials[i] = mul(factorials[i - 1], i); + invFactorials[factorials.length - 1] = exp(factorials[factorials.length - 1], mod - 2); + for (int i = invFactorials.length - 2; i >= 0; i--) + invFactorials[i] = mul(invFactorials[i + 1], i + 1); + } + + static long nCk(int n, int k) { + return mul(factorials[n], mul(invFactorials[k], invFactorials[n - k])); + } + + static void sort(int[] a) { + ArrayList l = new ArrayList<>(); + for (int i : a) + l.add(i); + Collections.sort(l); + for (int i = 0; i < a.length; i++) + a[i] = l.get(i); + } + + static class FastScanner { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(""); + + String next() { + while (!st.hasMoreTokens()) + try { + st = new StringTokenizer(br.readLine()); + } catch (IOException e) { + e.printStackTrace(); + } + return st.nextToken(); + } + + int nextInt() { + return Integer.parseInt(next()); + } + + int[] readArray(int n) { + int[] a = new int[n]; + for (int i = 0; i < n; i++) + a[i] = nextInt(); + return a; + } + + long nextLong() { + return Long.parseLong(next()); + } + } + +} diff --git a/112/index.html b/112/index.html new file mode 100644 index 0000000..1c977fa --- /dev/null +++ b/112/index.html @@ -0,0 +1,1035 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Problems - Codeforces + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+
+ + +
+ +
Codeforces Beta Round 85 (Div. 2 Only)
+
+ +
+
+ + + +
+
+ +
+ +
A. Petya and Strings
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. The letters' case does not matter, that is an uppercase letter is considered equivalent to the corresponding lowercase letter. Help Petya perform the comparison.

Input

Each of the first two lines contains a bought string. The strings' lengths range from 1 to 100 inclusive. It is guaranteed that the strings are of the same length and also consist of uppercase and lowercase Latin letters.

Output

If the first string is less than the second one, print "-1". If the second string is less than the first one, print "1". If the strings are equal, print "0". Note that the letters' case is not taken into consideration when the strings are compared.

Examples
Input
aaaa
aaaA
Output
0
Input
abs
Abz
Output
-1
Input
abcdefg
AbCdEfF
Output
1
Note

If you want more formal information about the lexicographical order (also known as the "dictionary order" or "alphabetical order"), you can visit the following site:

  • http://en.wikipedia.org/wiki/Lexicographical_order
+
+ + + + + +
+
+ + +
+ +
B. Petya and Square
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Little Petya loves playing with squares. Mum bought him a square 2n × 2n in size. Petya marked a cell inside the square and now he is solving the following task.

The task is to draw a broken line that would go along the grid lines and that would cut the square into two equal parts. The cutting line should not have any common points with the marked cell and the resulting two parts should be equal up to rotation.

Petya wants to determine whether it is possible to cut the square in the required manner given the sizes of the square side and the coordinates of the marked cell. Help him.

Input

The first line contains three space-separated integers 2n, x and y (2 ≤ 2n ≤ 100, 1 ≤ x, y ≤ 2n), representing the length of a square's side and the coordinates of the marked cell. It is guaranteed that 2n is even.

The coordinates of the marked cell are represented by a pair of numbers x y, where x represents the number of the row and y represents the number of the column. The rows and columns are numbered by consecutive integers from 1 to 2n. The rows are numbered from top to bottom and the columns are numbered from the left to the right.

Output

If the square is possible to cut, print "YES", otherwise print "NO" (without the quotes).

Examples
Input
4 1 1
Output
YES
Input
2 2 2
Output
NO
Note

A sample test from the statement and one of the possible ways of cutting the square are shown in the picture:

+
+ + + + + +
+
+ + +
+ +
C. Petya and Inequiations
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:

  • a12 + a22 + ... + an2 ≥ x
  • a1 + a2 + ... + an ≤ y
Input

The first line contains three space-separated integers n, x and y (1 ≤ n ≤ 105, 1 ≤ x ≤ 1012, 1 ≤ y ≤ 106).

Please do not use the %lld specificator to read or write 64-bit integers in С++. It is recommended to use cin, cout streams or the %I64d specificator.

Output

Print n positive integers that satisfy the conditions, one integer per line. If such numbers do not exist, print a single number "-1". If there are several solutions, print any of them.

Examples
Input
5 15 15
Output
4
4
1
1
2
Input
2 3 2
Output
-1
Input
1 99 11
Output
11
+
+ + + + + +
+
+ + +
+ +
D. Petya and Divisors
time limit per test
5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Little Petya loves looking for numbers' divisors. One day Petya came across the following problem:

You are given n queries in the form "xi yi". For each query Petya should count how many divisors of number xi divide none of the numbers xi - yi, xi - yi + 1, ..., xi - 1. Help him.

Input

The first line contains an integer n (1 ≤ n ≤ 105). Each of the following n lines contain two space-separated integers xi and yi (1 ≤ xi ≤ 105, 0 ≤ yi ≤ i - 1, where i is the query's ordinal number; the numeration starts with 1).

If yi = 0 for the query, then the answer to the query will be the number of divisors of the number xi. In this case you do not need to take the previous numbers x into consideration.

Output

For each query print the answer on a single line: the number of positive integers k such that

Examples
Input
6
4 0
3 1
5 2
6 2
18 4
10000 3
Output
3
1
1
2
2
22
Note

Let's write out the divisors that give answers for the first 5 queries:

1) 1, 2, 4

2) 3

3) 5

4) 2, 6

5) 9, 18

+
+ + + + + +
+
+ + +
+ +
E. Petya and Spiders
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Little Petya loves training spiders. Petya has a board n × m in size. Each cell of the board initially has a spider sitting on it. After one second Petya chooses a certain action for each spider, and all of them humbly perform its commands. There are 5 possible commands: to stay idle or to move from current cell to some of the four side-neighboring cells (that is, one command for each of the four possible directions). Petya gives the commands so that no spider leaves the field. It is allowed for spiders to pass through each other when they crawl towards each other in opposite directions. All spiders crawl simultaneously and several spiders may end up in one cell. Petya wants to know the maximum possible number of spider-free cells after one second.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 40, n·m ≤ 40) — the board sizes.

Output

In the first line print the maximum number of cells without spiders.

Examples
Input
1 1
Output
0
Input
2 3
Output
4
Note

In the first sample the only possible answer is:

s

In the second sample one of the possible solutions is:


rdl
rul

s denotes command "stay idle", l, r, d, u denote commands "crawl left", "crawl right", "crawl down", "crawl up", correspondingly.

+
+ + + + + +
+
+ + + +
+
+ + +