2 条题解
-
0武子涵@石湖中学 (武子涵) LV 10 @ 2021-03-13 13:42:42
//
#if 1//INCLUDE HEADERS
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <memory.h>
#include <sstream>
//MACROS
#define ll long long
#define MAX 65535
#define pause system("pause");
#define debug printf("__DEBUG__\n");
using namespace std;#define sigma 0.6180339887498949
int main() {
int n;
cin >> n;
vector<double>v;
int x;
for (int i = 0; i < n;++i)
{
cin >> x;
v.push_back(x);
v.push_back(x*sigma);
}
sort(v.begin(), v.end());int j = 0;
double min = MAX;
for (unsigned i = 1; i < v.size();++i)
{
if (v[i]-v[i-1]<min)
{
if ((int(v[i])==v[i])^(int(v[i-1])==v[i-1]))
{
min = v[i] - v[i - 1];
j = i;
}
}
}
if (int(v[j])==v[j])
{
cout << v[j] <<endl << int(v[j - 1] / sigma) << endl;
}
else {
cout << v[j - 1] << endl << int(v[j] / sigma) << endl;
}return 0;
}#endif
-
-12021-02-09 22:32:33@
//
#if 1//INCLUDE HEADERS
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <memory.h>
#include <sstream>
//MACROS
#define ll long long
#define MAX 65535
#define pause system("pause");
#define debug printf("__DEBUG__\n");
using namespace std;#define sigma 0.6180339887498949
int main() {
int n;
cin >> n;
vector<double>v;
int x;
for (int i = 0; i < n;++i)
{
cin >> x;
v.push_back(x);
v.push_back(x*sigma);
}
sort(v.begin(), v.end());int j = 0;
double min = MAX;
for (unsigned i = 1; i < v.size();++i)
{
if (v[i]-v[i-1]<min)
{
if ((int(v[i])==v[i])^(int(v[i-1])==v[i-1]))
{
min = v[i] - v[i - 1];
j = i;
}
}
}
if (int(v[j])==v[j])
{
cout << v[j] <<endl << int(v[j - 1] / sigma) << endl;
}
else {
cout << v[j - 1] << endl << int(v[j] / sigma) << endl;
}return 0;
}#endif
- 1