Skip to content

Commit 3366b6a

Browse files
committed
Added full Codeforces archive
1 parent d5c3dc6 commit 3366b6a

File tree

287 files changed

+20868
-702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

287 files changed

+20868
-702
lines changed

Codeforces/1/A[ Theatre Square ].java

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import java.util.*;
2+
import java.io.*;
3+
import java.math.*;
4+
5+
public class Main implements Runnable
6+
{
7+
public void solve() throws IOException
8+
{
9+
10+
long n = nextInt();
11+
long m = nextInt();
12+
long a = nextInt();
13+
14+
writer.println(((n+a-1)/a) * ((m+a-1)/a));
15+
}
16+
17+
public static void main(String[] args)
18+
{
19+
new Main().run();
20+
}
21+
22+
BufferedReader reader;
23+
StringTokenizer tokenizer;
24+
PrintWriter writer;
25+
26+
public void run()
27+
{
28+
try
29+
{
30+
reader = new BufferedReader(new InputStreamReader(System.in));
31+
tokenizer = null;
32+
writer = new PrintWriter(System.out);
33+
solve();
34+
reader.close();
35+
writer.close();
36+
}
37+
catch (Exception e)
38+
{
39+
e.printStackTrace();
40+
System.exit(1);
41+
}
42+
}
43+
44+
int nextInt() throws IOException
45+
{
46+
return Integer.parseInt(nextToken());
47+
}
48+
49+
long nextLong() throws IOException
50+
{
51+
return Long.parseLong(nextToken());
52+
}
53+
54+
double nextDouble() throws IOException
55+
{
56+
return Double.parseDouble(nextToken());
57+
}
58+
59+
BigInteger nextBigInteger() throws IOException
60+
{
61+
return new BigInteger(nextToken());
62+
}
63+
64+
String nextToken() throws IOException
65+
{
66+
while (tokenizer == null || !tokenizer.hasMoreTokens())
67+
{
68+
tokenizer = new StringTokenizer(reader.readLine());
69+
}
70+
return tokenizer.nextToken();
71+
}
72+
}

Codeforces/1/B[ Spreadsheet ].cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Alfonso2 Peterssen (mukel)
2+
#include <cstdio>
3+
#include <iostream>
4+
#include <sstream>
5+
6+
#include <algorithm>
7+
#include <vector>
8+
#include <queue>
9+
#include <stack>
10+
#include <deque>
11+
#include <set>
12+
#include <map>
13+
14+
#include <cstdlib>
15+
#include <cmath>
16+
#include <cstring>
17+
#include <complex>
18+
19+
using namespace std;
20+
21+
typedef long long int64;
22+
23+
#define SZ(c) ((int)(c).size())
24+
#define ALL(c) (c).begin(), (c).end()
25+
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
26+
#define FOR(i, l, h) for (int i = (int)(l); i <= (int)(h); ++i)
27+
#define FOREACH(it, c) for (typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
28+
29+
int Q;
30+
string line;
31+
int row, col;
32+
char buf[100];
33+
34+
int main()
35+
{
36+
ios_base::sync_with_stdio(false);
37+
38+
for (cin >> Q; Q--;)
39+
{
40+
cin >> line;
41+
if (sscanf( line.c_str(), "R%dC%d", &row, &col ) == 2)
42+
{
43+
string ans;
44+
while (col > 0)
45+
{
46+
col--;
47+
ans += (char)(&#39;A&#39; + col % 26);
48+
col /= 26;
49+
}
50+
reverse(ALL(ans));
51+
cout << ans << row << "\n";
52+
}
53+
else
54+
{
55+
sscanf( line.c_str(), "%[A-Z]%d", &buf, &row );
56+
col = 0;
57+
for (int i = 0; buf[i]; ++i)
58+
col = col * 26 + (buf[i] - &#39;A&#39; + 1);
59+
cout << "R" << row << "C" << col << "\n";
60+
}
61+
}
62+
63+
64+
65+
return 0;
66+
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// Alfonso2 Peterssen (mukel)
2+
#include <cstdio>
3+
#include <iostream>
4+
#include <sstream>
5+
6+
#include <algorithm>
7+
#include <vector>
8+
#include <queue>
9+
#include <stack>
10+
#include <deque>
11+
#include <set>
12+
#include <map>
13+
14+
#include <cstdlib>
15+
#include <cmath>
16+
#include <cstring>
17+
#include <complex>
18+
19+
using namespace std;
20+
21+
typedef long long int64;
22+
23+
#define SZ(c) ((int)(c).size())
24+
#define ALL(c) (c).begin(), (c).end()
25+
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
26+
#define FOR(i, l, h) for (int i = (int)(l); i <= (int)(h); ++i)
27+
#define FOREACH(it, c) for (typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
28+
29+
typedef complex< double > point;
30+
31+
#define xx real()
32+
#define yy imag()
33+
34+
35+
point rotate(const point p, double angle)
36+
{
37+
return p * point(cos(angle), sin(angle));
38+
}
39+
40+
point rotateAt(point p, point at, double angle)
41+
{
42+
return rotate(p - at, angle) + at;
43+
}
44+
45+
point perp(const point p)
46+
{
47+
return point(-p.yy, p.xx);
48+
}
49+
50+
const double EPS = 1e-5;
51+
52+
point cutPoint(point p1, point p2, point q1, point q2)
53+
{
54+
double a1 = p2.yy - p1.yy;
55+
double b1 = p1.xx - p2.xx;
56+
double c1 = a1 * p1.xx + b1 * p1.yy;
57+
58+
double a2 = q2.yy - q1.yy;
59+
double b2 = q1.xx - q2.xx;
60+
double c2 = a2 * q1.xx + b2 * q1.yy;
61+
62+
double det = a1 * b2 - a2 * b1;
63+
64+
return point((b2 * c1 - b1 * c2) / det, (a1 * c2 - a2 * c1) / det);
65+
}
66+
67+
68+
double sqr(double x)
69+
{
70+
return x * x;
71+
}
72+
73+
double dist(point a, point b)
74+
{
75+
return sqrt(sqr(a.xx - b.xx) + sqr(a.yy - b.yy));
76+
}
77+
78+
point readPoint()
79+
{
80+
double x, y;
81+
cin >> x >> y;
82+
return point(x, y);
83+
}
84+
85+
point A, B, C;
86+
87+
int main()
88+
{
89+
ios_base::sync_with_stdio(false);
90+
91+
/*
92+
cout << "0 0" << endl;
93+
cout << "1 0" << endl;
94+
cout << cos(M_PI/3) << " " << sin(M_PI/3) << endl;
95+
return 0;*/
96+
97+
A = readPoint();
98+
B = readPoint();
99+
C = readPoint();
100+
101+
A -= C;
102+
B -= C;
103+
104+
point a2 = A * 0.5;
105+
point b2 = B * 0.5;
106+
107+
point center = cutPoint(a2, a2 + perp(A), b2, b2 + perp(B));
108+
109+
//cout << "center = " << center.xx << " " << center.yy << endl;
110+
111+
for (int i = 3; i <= 100; ++i)
112+
{
113+
double innerAngle = 2 * M_PI / i;//M_PI * (i - 2) / i;
114+
115+
int cnt = 0;
116+
for (int j = 1; j < i; ++j)
117+
{
118+
point p = rotateAt(point(0, 0), center, j * innerAngle);
119+
if (dist(p, A) < EPS) cnt++;
120+
if (dist(p, B) < EPS) cnt++;
121+
122+
}
123+
124+
if (cnt == 2)
125+
{
126+
//cout << i << endl;
127+
double r = dist(point(0, 0), center);
128+
double area = i * r * r * sin(2 * M_PI / i) / 2;
129+
printf( "%.12lf\n", area );
130+
break;
131+
}
132+
}
133+
134+
return 0;
135+
}
136+
137+
138+
139+

Codeforces/101/A[ Homework ].cpp

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
Alfonso2 Peterssen(mukel)
3+
Universidad de La Habana
4+
Codeforces Round 79 Beta Div. 1
5+
*/
6+
#include <cstdio>
7+
#include <iostream>
8+
#include <sstream>
9+
10+
#include <algorithm>
11+
#include <numeric>
12+
#include <vector>
13+
#include <deque>
14+
#include <queue>
15+
#include <stack>
16+
#include <set>
17+
#include <map>
18+
19+
#include <cstdlib>
20+
#include <cstring>
21+
#include <cmath>
22+
#include <complex>
23+
24+
using namespace std;
25+
26+
typedef long long int64;
27+
28+
#define PB(x) push_back(x)
29+
#define SZ(c) ((int)((c).size()))
30+
#define MP(x, y) make_pair((x), (y))
31+
#define ALL(c) (c).begin(), (c).end()
32+
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
33+
#define FOR(i, b, e) for (int i = (int)b; i <= (int)(e); ++i)
34+
#define FOREACH(it, c) for (typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
35+
#define DBG(x) cout << #x << " = " << x << endl
36+
37+
const int ALPHA = 1 << 8;
38+
39+
int N, K;
40+
char buf[1 << 18];
41+
int del[ALPHA];
42+
int freq[ALPHA];
43+
int order[ALPHA];
44+
int cnt;
45+
46+
bool myComp(int i, int j)
47+
{
48+
return freq[i] < freq[j];
49+
}
50+
51+
int main()
52+
{
53+
scanf( "%s", &buf );
54+
scanf( "%d", &K );
55+
56+
int n = strlen(buf);
57+
58+
REP(i, n)
59+
freq[ buf[i] ]++;
60+
61+
REP(i, ALPHA) if (freq[i])
62+
order[cnt++] = i;
63+
64+
sort(order, order + cnt, myComp);
65+
66+
67+
int remain = cnt;
68+
69+
REP(i, cnt)
70+
{
71+
int j = order[i];
72+
if (K - freq[j] >= 0)
73+
{
74+
del[j] = true;
75+
remain--;
76+
K -= freq[j];
77+
}
78+
}
79+
80+
printf( "%d\n", remain );
81+
82+
REP(i, n)
83+
if (!del[ buf[i] ]) printf( "%c", buf[i] );
84+
85+
printf( "\n" );
86+
87+
return 0;
88+
}

0 commit comments

Comments
 (0)