Skip to content

Commit bed6cf9

Browse files
committed
yandex contest 2017 round 1 and others
1 parent 0645dd9 commit bed6cf9

File tree

17 files changed

+875
-0
lines changed

17 files changed

+875
-0
lines changed

acm.timus.ru/1000-1100/1084.java

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import java.io.OutputStream;
2+
import java.io.IOException;
3+
import java.io.InputStream;
4+
import java.io.PrintWriter;
5+
import java.util.Scanner;
6+
7+
/**
8+
* Built using CHelper plug-in
9+
* Actual solution is at the top
10+
*
11+
* @author kronos
12+
*/
13+
public class Main {
14+
public static void main(String[] args) {
15+
InputStream inputStream = System.in;
16+
OutputStream outputStream = System.out;
17+
Scanner in = new Scanner(inputStream);
18+
PrintWriter out = new PrintWriter(outputStream);
19+
Task1084 solver = new Task1084();
20+
solver.solve(1, in, out);
21+
out.close();
22+
}
23+
24+
static class Task1084 {
25+
public void solve(int testNumber, Scanner in, PrintWriter out) {
26+
double a = in.nextDouble();
27+
double l = in.nextDouble();
28+
double pi = 3.1415926535;
29+
if (a / 2.0 - l >= 1e-6) {
30+
out.printf("%.3f", pi * l * l);
31+
} else if ((double) l - Math.sqrt(2 * a * a) / 2.0 >= 1e-6) {
32+
out.printf("%.3f", a * a);
33+
} else {
34+
double d = a / 2.0;
35+
double segment = l * l * Math.acos(d / l) - d * Math.sqrt(l * l - d * d);
36+
out.printf("%.3f", pi * l * l - segment * 4.0);
37+
}
38+
}
39+
40+
}
41+
}
42+

acm.timus.ru/1201-1300/1246.java

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import java.io.OutputStream;
2+
import java.io.IOException;
3+
import java.io.InputStream;
4+
import java.io.PrintWriter;
5+
import java.io.IOException;
6+
import java.io.InputStreamReader;
7+
import java.io.FileNotFoundException;
8+
import java.util.StringTokenizer;
9+
import java.io.BufferedReader;
10+
import java.io.FileReader;
11+
import java.io.InputStream;
12+
13+
/**
14+
* Built using CHelper plug-in
15+
* Actual solution is at the top
16+
*
17+
* @author kronos
18+
*/
19+
public class Main {
20+
public static void main(String[] args) {
21+
InputStream inputStream = System.in;
22+
OutputStream outputStream = System.out;
23+
FastScanner in = new FastScanner(inputStream);
24+
PrintWriter out = new PrintWriter(outputStream);
25+
Task1246 solver = new Task1246();
26+
solver.solve(1, in, out);
27+
out.close();
28+
}
29+
30+
static class Task1246 {
31+
public void solve(int testNumber, FastScanner in, PrintWriter out) {
32+
int n = in.nextInt() - 1;
33+
long z = 0, fx, fy;
34+
long x1, y1, x2 = 0, y2 = 0;//,x3,y3;
35+
fx = x1 = in.nextLong();
36+
fy = y1 = in.nextLong();
37+
while (n > 0) {
38+
x2 = in.nextLong();
39+
y2 = in.nextLong();
40+
z += x1 * y2 - x2 * y1;
41+
x1 = x2;
42+
y1 = y2;
43+
n--;
44+
}
45+
46+
z += x2 * fy - fx * y2;
47+
48+
if (z < 0) {
49+
out.println("cw");
50+
} else {
51+
out.println("ccw");
52+
}
53+
}
54+
55+
}
56+
57+
static class FastScanner {
58+
BufferedReader br;
59+
StringTokenizer st;
60+
61+
public FastScanner() {
62+
br = new BufferedReader(new InputStreamReader(System.in));
63+
}
64+
65+
public FastScanner(InputStream stream) {
66+
br = new BufferedReader(new InputStreamReader(stream));
67+
}
68+
69+
public FastScanner(String s) {
70+
try {
71+
br = new BufferedReader(new FileReader(s));
72+
} catch (FileNotFoundException e) {
73+
e.printStackTrace();
74+
}
75+
}
76+
77+
public String next() {
78+
while (st == null || !st.hasMoreTokens()) {
79+
try {
80+
st = new StringTokenizer(br.readLine());
81+
} catch (IOException e) {
82+
}
83+
}
84+
return st.nextToken();
85+
}
86+
87+
public int nextInt() {
88+
return Integer.parseInt(next());
89+
}
90+
91+
public long nextLong() {
92+
return Long.parseLong(next());
93+
}
94+
95+
}
96+
}

codeforces/gyms/100985/a.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <algorithm>
4+
#include <set>
5+
#include <map>
6+
7+
using namespace std;
8+
int n;
9+
long long a,b;
10+
11+
int main() {
12+
cin.tie(0);
13+
ios_base::sync_with_stdio(false);
14+
15+
cin >> n;
16+
while (n--) {
17+
cin >> a >> b;
18+
if (__gcd(a,b) > 1) {
19+
cout << "Sim\n";
20+
} else {
21+
cout << "Nao\n";
22+
}
23+
}
24+
return 0;
25+
}

codeforces/gyms/100985/b.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <algorithm>
4+
#include <set>
5+
#include <map>
6+
#include <math.h>
7+
8+
using namespace std;
9+
int n;
10+
unsigned ans;
11+
12+
int main() {
13+
cin.tie(0);
14+
ios_base::sync_with_stdio(false);
15+
16+
cin >> n;
17+
ans = log2(n) + 1;
18+
cout << ans << endl;
19+
return 0;
20+
}

codeforces/gyms/100985/c.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <algorithm>
4+
#include <set>
5+
#include <map>
6+
7+
using namespace std;
8+
int x, y, i, q;
9+
10+
int main() {
11+
cin >> x >> y;
12+
13+
if (x > y) {
14+
cout << "1 " << x-y << endl;
15+
x -= x-y;
16+
} else {
17+
cout << "2 " << y-x << endl;
18+
y -= y-x;
19+
}
20+
21+
while (x > 0 || y > 0) {
22+
cin >> i >> q;
23+
24+
if (i == 1) {
25+
x -= q;
26+
} else {
27+
y -= q;
28+
}
29+
30+
if (x > y) {
31+
cout << "1 " << x-y << endl;
32+
x -= x-y;
33+
} else {
34+
cout << "2 " << y-x << endl;
35+
y -= y-x;
36+
}
37+
}
38+
39+
return 0;
40+
}

0 commit comments

Comments
 (0)