-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
326 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import java.util.*; | ||
import java.io.*; | ||
|
||
import static java.lang.Math.*; | ||
|
||
public class Autocomplete { | ||
public static void main(String[] args) throws IOException { | ||
BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); | ||
|
||
String pref = input.readLine(); | ||
|
||
int i; | ||
int N = Integer.parseInt(input.readLine()); | ||
|
||
String ans = "%"; | ||
|
||
for (i = 0; i < N; i++) { | ||
String curr = input.readLine(); | ||
|
||
if (curr.startsWith(pref) && (ans.equals("%") || curr.compareTo(ans) < 0)) { | ||
ans = curr; | ||
} | ||
} | ||
|
||
System.out.println(ans == "%" ? pref : ans); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import java.util.*; | ||
import java.io.*; | ||
|
||
import static java.lang.Math.*; | ||
|
||
public class BlogPhoto { | ||
public static final double EPS = 1e-7; | ||
|
||
public static void main(String[] args) throws IOException { | ||
BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); | ||
|
||
String[] sp = input.readLine().split(" "); | ||
|
||
int H = Integer.parseInt(sp[0]); | ||
int W = Integer.parseInt(sp[1]); | ||
|
||
int base; | ||
long ans = 0L; | ||
|
||
int ans_H = 0; | ||
int ans_W = 0; | ||
|
||
base = 0; | ||
for (; pow(2.0, base) <= W; base++) { | ||
long cw = (long) pow(2.0, base); | ||
long ch = Math.min(H, (long) cw * 5 / 4); | ||
|
||
long ratio = cw * ch; | ||
|
||
if (ch * 4 > cw * 5) continue; | ||
|
||
if (ratio > ans || (ratio == ans && ch > ans_H)) { | ||
ans_H = (int) ch; | ||
ans_W = (int) cw; | ||
ans = ratio; | ||
} | ||
} | ||
|
||
base = 0; | ||
for (; pow(2.0, base) <= H; base++) { | ||
long ch = (long) pow(2.0, base); | ||
long cw = Math.min(W, (long) ch * 5 / 4); | ||
|
||
long ratio = cw * ch; | ||
|
||
if (ch * 4 > cw * 5) continue; | ||
|
||
if (ratio > ans || (ratio == ans && ch > ans_H)) { | ||
ans_H = (int) ch; | ||
ans_W = (int) cw; | ||
ans = ratio; | ||
} | ||
} | ||
|
||
|
||
System.out.printf("%d %d\n", ans_H, ans_W); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import sys | ||
|
||
N = int(input()) | ||
|
||
id = 0 | ||
ans = [0 for _ in range(N) ] | ||
|
||
for i in range(0, N - 1, 2): | ||
ans[i] = id + 1; | ||
ans[i + 1] = N - id | ||
id = id + 1 | ||
|
||
if N % 2 == 1: | ||
ans[N - 1] = N // 2 + 1 | ||
|
||
for i in ans: | ||
sys.stdout.write(str(i) + " ") | ||
print() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <bits/stdc++.h> | ||
|
||
template<typename T> T gcd(T a, T b) { | ||
if(!b) return a; | ||
return gcd(b, a % b); | ||
} | ||
template<typename T> T lcm(T a, T b) { | ||
return a * b / gcd(a, b); | ||
} | ||
|
||
template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; } | ||
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; } | ||
int in() { int x; scanf("%d", &x); return x; } | ||
|
||
using namespace std; | ||
|
||
typedef long long Int; | ||
typedef unsigned uint; | ||
|
||
const int MAXN = 330; | ||
|
||
int N; | ||
int A[MAXN]; | ||
int B[MAXN]; | ||
|
||
int main(void) { | ||
N = in(); | ||
|
||
vector<pair<int, int> > ans; | ||
|
||
int i; | ||
int j; | ||
|
||
for (i = 0; i < N; i++) A[i] = in(); | ||
for (i = 0; i < N; i++) B[i] = in(); | ||
|
||
for (i = 0; i < N; i++) if (A[i] != B[i]) { | ||
int pos = i; | ||
for (j = i + 1; j < N; j++) if (B[j] == A[i]) { | ||
pos = j; | ||
break; | ||
} | ||
|
||
for ( ; pos != i; ) { | ||
ans.push_back(make_pair(pos, pos + 1)); | ||
swap(B[pos], B[pos - 1]); | ||
pos = pos - 1; | ||
} | ||
} | ||
|
||
printf("%d\n", (int) ans.size()); | ||
|
||
for (i = 0; i < (int) ans.size(); i++) { | ||
printf("%d %d\n", ans[i].first, ans[i].second); | ||
} | ||
|
||
return 0; | ||
} |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,3 @@ | ||
<<<<<<< HEAD | ||
yxzyzxzzxyyzzxxxzyyzzyzxxzxyzyyzxyzxyxxyzxyxzyzxyzxyyxzzzyzxyyxyzxxy | ||
10 | ||
17 67 | ||
6 35 | ||
12 45 | ||
56 56 | ||
14 30 | ||
25 54 | ||
1 1 | ||
46 54 | ||
3 33 | ||
19 40 | ||
======= | ||
5 2 | ||
1 2 | ||
2 3 | ||
>>>>>>> f82b26d6bc5f261bf48e4c5a18f849e6ce544345 | ||
2 | ||
1 100500 | ||
1 100500 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <bits/stdc++.h> | ||
|
||
template<typename T> T gcd(T a, T b) { | ||
if(!b) return a; | ||
return gcd(b, a % b); | ||
} | ||
template<typename T> T lcm(T a, T b) { | ||
return a * b / gcd(a, b); | ||
} | ||
|
||
template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; } | ||
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; } | ||
int in() { int x; scanf("%d", &x); return x; } | ||
|
||
using namespace std; | ||
|
||
typedef long long Int; | ||
typedef unsigned uint; | ||
|
||
const double EPS = 1e-8; | ||
|
||
int T; | ||
double R, B, M; | ||
|
||
int main(void) { | ||
T = in(); | ||
|
||
for ( ; T--; ) { | ||
scanf("%lf%lf%lf", &R, &B, &M); | ||
|
||
int x = 0; | ||
double last = 1001010.0; | ||
|
||
for ( ; B > 0 && x++ <= 1200 && B < last; ) { | ||
last = B; | ||
|
||
B = B * (1.0 + R / 100.0); | ||
B = (int) (B * 100.0 + 0.5 + EPS) / 100.0; | ||
B -= M; | ||
} | ||
|
||
if (x > 1200 || B >= last) { | ||
puts("impossible"); | ||
} else { | ||
printf("%d\n", x); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
1199 | ||
1200 | ||
impossible | ||
impossible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
5 | ||
1 | ||
2 | ||
100 | ||
1000 | ||
999 | ||
4 | ||
0.01 11.99 0.01 | ||
0.01 12.00 0.01 | ||
0.01 12.01 0.01 | ||
0.01 12.02 0.01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
1 | ||
impossible | ||
impossible | ||
impossible |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#include <cstdio> | ||
#include <cmath> | ||
#include <cstring> | ||
#include <ctime> | ||
#include <iostream> | ||
#include <algorithm> | ||
#include <set> | ||
#include <vector> | ||
#include <sstream> | ||
#include <typeinfo> | ||
|
||
using namespace std; | ||
|
||
class MakeSquare { | ||
public: | ||
int minChanges(string S) { | ||
return 0; | ||
} | ||
}; | ||
|
||
// CUT begin | ||
template <typename T> string pretty_print(T t) { stringstream s; typeid(T) == typeid(string) ? s << "\"" << t << "\"" : s << t; return s.str(); } | ||
|
||
bool do_test(string S, int __expected, int caseNo) { | ||
cout << " Testcase #" << caseNo << " ... "; | ||
|
||
time_t startClock = clock(); | ||
MakeSquare *instance = new MakeSquare(); | ||
int __result = instance->minChanges(S); | ||
double elapsed = (double)(clock() - startClock) / CLOCKS_PER_SEC; | ||
delete instance; | ||
|
||
if (__result == __expected) { | ||
cout << "PASSED!" << " (" << elapsed << " seconds)" << endl; | ||
return true; | ||
} | ||
else { | ||
cout << "FAILED!" << " (" << elapsed << " seconds)" << endl; | ||
cout << " Expected: " << pretty_print(__expected) << endl; | ||
cout << " Received: " << pretty_print(__result) << endl; | ||
return false; | ||
} | ||
} | ||
|
||
bool run_testcase(int __no) { | ||
switch (__no) { | ||
case 0: { | ||
string S = "abcdabgcd"; | ||
int __expected = 1; | ||
return do_test(S, __expected, __no); | ||
} | ||
case 1: { | ||
string S = "abcdeabce"; | ||
int __expected = 1; | ||
return do_test(S, __expected, __no); | ||
} | ||
case 2: { | ||
string S = "abcdeabxde"; | ||
int __expected = 1; | ||
return do_test(S, __expected, __no); | ||
} | ||
case 3: { | ||
string S = "aabcaabc"; | ||
int __expected = 0; | ||
return do_test(S, __expected, __no); | ||
} | ||
case 4: { | ||
string S = "aaaaabaaaaabaaaaa"; | ||
int __expected = 2; | ||
return do_test(S, __expected, __no); | ||
} | ||
|
||
// Your custom testcase goes here | ||
case 5: | ||
break; | ||
default: break; | ||
} | ||
return 0; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
cout.setf(ios::fixed,ios::floatfield); | ||
cout.precision(2); | ||
cout << "MakeSquare (1000 Points)" << endl << endl; | ||
|
||
int nPassed = 0, nAll = 0; | ||
if (argc == 1) | ||
for (int i = 0; i < 5; ++i) nAll++, nPassed += run_testcase(i); | ||
else | ||
for (int i = 1; i < argc; ++i) nAll++, nPassed += run_testcase(atoi(argv[i])); | ||
cout << endl << "Passed : " << nPassed << "/" << nAll << " cases" << endl; | ||
|
||
int T = time(NULL) - 1385687788; | ||
double PT = T / 60.0, TT = 75.0; | ||
cout << "Time : " << T / 60 << " minutes " << T % 60 << " secs" << endl; | ||
cout << "Score : " << 1000 * (0.3 + (0.7 * TT * TT) / (10.0 * PT * PT + TT * TT)) << " points" << endl; | ||
return 0; | ||
} | ||
// CUT end |