Pagini recente » Cod sursa (job #402542) | Cod sursa (job #2783744) | Cod sursa (job #2014070) | Cod sursa (job #783732) | Cod sursa (job #1301426)
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <vector>
#include <limits>
#include <iterator>
#include <iomanip>
#include <algorithm>
#include <cmath>
#define FIN "cmap.in"
#define FOUT "cmap.out"
namespace std {
inline istream& operator>>(istream& in, pair<int,int>& x) {
in>>x.first>>x.second;
return in;
}
}
using namespace std;
typedef pair<int, int> point;
typedef long long int LLI;
vector<point> Po;
int N;
LLI dist = numeric_limits<LLI>::max();
ifstream in( FIN );
ofstream out( FOUT );
inline LLI dis(const point& x, const point& y)
{
return 1LL * (x.first - y.first) * (x.first - y.first) +
1LL * (x.second - y.second) * (x.second - y.second);
}
LLI distance(const point& a,const point& b) {
}
int main() {
in>>N;
copy(istream_iterator<point>(in), istream_iterator<point>(), back_inserter( Po ));
sort(Po.begin(), Po.end());
for(int i = 0; i < N; ++i)
{
for(int j = i + 1; j < N; ++j)
{
if( 1LL * (Po[j].first - Po[i].first) * (Po[j].first - Po[i].first) > dist) break;
dist = min(dist, dis(Po[j], Po[i]));
}
}
out << setprecision(6) << fixed << sqrt(dist) << endl;
return(0);
};