Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
D three integers
/* author : masaow g++ : 17.3.20 */ #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #define forn(i,a,b) for( i = a ; i < b ; i++ ) #define debug(x) cout << #x << " " << x << " -- " #define I__O ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL) #define ll long long #define MOD 100000007 #define pi pair<int,int> #define vi vector <int> #define pb push_back #define vp vector <pair<ll,ll>> #define endl cout << "\n" #define mi map <int,int> #define f1 first #define s1 second #define in insert #define all(x) x.begin(),x.end() using namespace std ; using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set ; const int N = 2e5+7; /* time : 10 : 14 date : 24.02.2020 */ // int L,R,mid,target,idx ; int A,B,C ; int tests() { int i ; cin >> A >> B >> C ; /* map <int,vector <int>> m ; forn(i,1,1e2+1){ vector <int> v(3) ; v[0] = i ; v[1] = B-B%i ; if(v[1]){ v[2] = C-C%v[1] ; m[B%i+C%v[1]+abs(A-i)] = v ; cout << v[0] << ' ' << v[1] << ' ' << v[2] << '\n' ; v[2] = (((C+v[1]-1)/v[1])*v[1]) ; m[B%i+v[2]-C+abs(A-i)] = v; cout << v[0] << ' ' << v[1] << ' ' << v[2] << '\n' ; } v[1] = ((B+i-1)/i)*i ; if(v[1]){ v[2] = C-C%v[1] ; m[v[1]-B+C%v[1]+abs(A-i)] = v; cout << v[0] << ' ' << v[1] << ' ' << v[2] << '\n' ; v[2] = (((C+v[1]-1)/v[1])*v[1]) ; m[v[1]-B+v[2]-C + abs(A-i)] = v; cout << v[0] << ' ' << v[1] << ' ' << v[2] << '\n' ; } } cout << m.begin()->first << '\n' ; forn(i,0,3) cout << m.begin()->second[i] << ' ' ; cout << '\n' ;*/ set <set<int>> v ; set <int> s ; forn(i,1,1e4+1) for( int j = 1 ; j*j <= i ; j++ ) if(i%j ==0 ){ int T = j ; for( int k = 1 ; k*k <= T ; k++ ) if(j%k == 0){ int T1 = k ; s.clear() ; s.insert(i) ; s.insert(T) ; s.insert(T1) ; v.insert(s) ; T1 = T/k ; s.clear() ; s.insert(i) ; s.insert(T) ; s.insert(T1) ; v.insert(s) ; } T = i/j ; for( int k = 1 ; k*k <= T; k++ ) if(j%k == 0){ int T1 = k ; s.clear() ; s.insert(i) ; s.insert(T) ; s.insert(T1) ; v.insert(s) ; T1 = T/k ; s.clear() ; s.insert(i) ; s.insert(T) ; s.insert(T1) ; v.insert(s) ; } } cout << v.size() << ' ' ; map <int,int> m ; vector <int> F(3) ; int pre = 2e9+7 ; for(auto it : v){ vector <int> v1 ; for(auto x : it ) v1.pb(x) ; vector <int> V{A,B,C} ; sort(all(V)) ; int T = abs(V[0]-v1[0]) ; T += abs(V[1]-v1[1]) ; T += abs(V[2]-v1[2]) ; //cout << T << '\n' ; if(T < pre ){ pre = T ; F = V ; m[F[0]] = v1[0] ; m[F[1]] = v1[1] ; m[F[2]] = v1[2] ; } } cout << pre << '\n' ; forn(i,0,3) cout << m[F[i]] <<' ' ; cout << '\n' ; return 0; } int main(){ I__O ; int cases = 1 ; cin >> cases; while(cases--) tests(); return 0 ; }
run
|
edit
|
history
|
help
0
container store pointer
bin search
SayHi
D.E.Shaw Binary Search Question
Make Bin Tree
my template
a simple tuple implementation
simple serialization
ExceptionHandling3
MoveBubble