parent
86354a36fe
commit
ea9b23f700
@ -1,18 +0,0 @@
|
|||||||
#include <bits/stdc++.h>
|
|
||||||
using namespace std;
|
|
||||||
int main() {
|
|
||||||
int n, d;
|
|
||||||
cin >> n >> d;
|
|
||||||
double x = 1.0 * n / d;
|
|
||||||
double pre = round(x);
|
|
||||||
cout << pre << "/1" << endl;
|
|
||||||
for (int i = 1; i <= d; i++) {
|
|
||||||
for (int j = 1; j <= n; j++) {
|
|
||||||
double cur = 1.0 * j / i;
|
|
||||||
if (abs(cur - x) >= abs(pre - x)) continue;
|
|
||||||
cout << j << "/" << i << endl;
|
|
||||||
pre = cur;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -0,0 +1,75 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using std::sort;
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
int n, flag, axis;
|
||||||
|
string inStr, ans;
|
||||||
|
struct point {
|
||||||
|
int x, y;
|
||||||
|
char v; // value
|
||||||
|
};
|
||||||
|
std::vector<point> pt;
|
||||||
|
struct point inf;
|
||||||
|
|
||||||
|
bool comp(const point &a, const point &b) {
|
||||||
|
if (a.v == b.v) {
|
||||||
|
return (a.x == b.x) ? (a.y < b.y) : (a.x < b.x);
|
||||||
|
} else {
|
||||||
|
return a.v < b.v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
cin >> n >> inStr;
|
||||||
|
flag = 0, axis = 0;
|
||||||
|
for (register int count = 0; count < n; ++count) {
|
||||||
|
for (register int countB = 0; countB < count + 1; ++countB) {
|
||||||
|
point newPt;
|
||||||
|
newPt.v = inStr[flag];
|
||||||
|
newPt.y = count;
|
||||||
|
newPt.x = axis + (countB << 1);
|
||||||
|
++flag;
|
||||||
|
pt.push_back(newPt);
|
||||||
|
// used for debug
|
||||||
|
// cout<<newPt.v<<' '<<newPt.x<<' '<<newPt.y<<endl;
|
||||||
|
// end debug
|
||||||
|
}
|
||||||
|
--axis;
|
||||||
|
}
|
||||||
|
inf.x = (1 << 8), inf.y = (1 << 8), inf.v = '~';
|
||||||
|
pt.push_back(inf);
|
||||||
|
sort(pt.begin(), pt.end(), comp);
|
||||||
|
for (register int count = 0; count <= flag; ++count) {
|
||||||
|
if (pt[count].v == '~') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// used for debug
|
||||||
|
// cout<<'*'<<pt[count].v<<' '<<pt[count-1].v<<' '<<pt[count-2].v<<endl;
|
||||||
|
// end debug
|
||||||
|
if (pt[count].v != pt[count + 1].v) {
|
||||||
|
if (pt[count - 2].v == pt[count].v) {
|
||||||
|
int dist[3];
|
||||||
|
dist[0] = (pt[count - 2].x - pt[count - 1].x) * (pt[count - 2].x - pt[count - 1].x)
|
||||||
|
+ 3 * (pt[count - 2].y - pt[count - 1].y) * (pt[count - 2].y - pt[count - 1].y);
|
||||||
|
dist[1] = (pt[count - 2].x - pt[count].x) * (pt[count - 2].x - pt[count].x)
|
||||||
|
+ 3 * (pt[count - 2].y - pt[count].y) * (pt[count - 2].y - pt[count].y);
|
||||||
|
dist[2] = (pt[count - 1].x - pt[count].x) * (pt[count - 1].x - pt[count].x)
|
||||||
|
+ 3 * (pt[count - 1].y - pt[count].y) * (pt[count - 1].y - pt[count].y);
|
||||||
|
// used for debug
|
||||||
|
// cout<<'*'<<pt[count].v<<' '<<dist[0]<<' '<<dist[1]<<' '<<dist[2]<<endl;
|
||||||
|
// end debug
|
||||||
|
if (dist[1] == dist[2] && dist[0] == dist[1]) {
|
||||||
|
ans = ans + pt[count].v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ans != "") {
|
||||||
|
cout << ans << endl;
|
||||||
|
} else {
|
||||||
|
puts("No Solution");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
10
|
||||||
|
abccddadca
|
Loading…
Reference in new issue