-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom.cpp
More file actions
60 lines (54 loc) · 1.92 KB
/
Copy pathrandom.cpp
File metadata and controls
60 lines (54 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "bits/stdc++.h"
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}
using namespace std;
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 2003;
int main(){
double x,y; cin >> x >> y;
int cnt = 0;
int xx,yy; xx = int(1000*x); yy = int(1000*y);
set<pair<ll,ll>> st;
vector<int> X,Y;
REP(i,-5,6)
REP(j,-5,6){X.pb(ll(x)+i); Y.pb(ll(y)+i);}
std::mt19937 engine(chrono::steady_clock::now().time_since_epoch().count());
rep(i,25){
if((1000*X[i]==xx && 1000*Y[i]==yy)) continue;
rep(j,int(1e6)){
int x2 = engine()%20000 - 10000;
ll h = ll(yy-1000*Y[i])*ll(x2-X[i]);
if(xx-1000*X[i]==0LL) continue;
bool ok = (h%ll(xx-1000*X[i])==0);
if(ok){
int y2 = Y[i] + h/(xx-1000*X[i]);
if(abs(X[i])>10000 || abs(Y[i])>10000|| abs(x2)>10000 || abs(y2)>10000) continue;
if((1000*x2==xx && 1000*y2==yy) || (X[i]==x2&&Y[i]==y2)) continue;
ll g;
if((yy-1000*y2)*(X[i]-x2)!=(Y[i]-y2)*(xx-1000*x2)) continue;
if(yy-1000*Y[i]==0LL) g = xx-1000*X[i];
else g = __gcd(xx-1000*X[i],yy-1000*Y[i]);
if(st.count(Pl((xx-1000*X[i])/g,(yy-1000*Y[i])/g))) continue;
cout << X[i] << " " << Y[i] << " " << x2 << " " << y2 << endl;
st.insert(Pl((xx-1000*X[i])/g,(yy-1000*Y[i])/g));
cnt++; break;
}
}
if(cnt==2) break;
}
return 0;
}