結果
| 問題 | No.1006 Share an Integer |
| コンテスト | |
| ユーザー |
iqueue02
|
| 提出日時 | 2020-03-06 22:08:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 987 bytes |
| コンパイル時間 | 1,650 ms |
| コンパイル使用メモリ | 176,520 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-10-14 07:12:36 |
| 合計ジャッジ時間 | 5,258 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 TLE * 1 -- * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9;
vector<long long> divisor(long long n){
vector<long long> res;
for(long long i = 1; i*i <= n; i++){
if(n%i==0){
res.push_back(i);
if(n/i != i)res.push_back(n/i);
}
}
return res;
}
int main(){
int x;
cin >> x;
set<P> st;
int mx = INF;
for (int a = 1; a + a <= x; a++) {
int b = x - a;
auto d1 = divisor(a);
auto d2 = divisor(b);
int f1 = a - d1.size(), f2 = b - d2.size();
int v = abs(f1 - f2);
if (v < mx) {
mx = v;
st.clear();
st.insert(make_pair(a, b));
st.insert(make_pair(b, a));
} else if (v == mx) {
st.insert(make_pair(a, b));
st.insert(make_pair(b, a));
}
}
for (auto e : st) {
cout << e.first << " " << e.second << endl;
}
return 0;
}
iqueue02