結果

問題 No.1006 Share an Integer
ユーザー kyoprounokyoprouno
提出日時 2020-03-09 19:12:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,064 bytes
コンパイル時間 1,951 ms
コンパイル使用メモリ 174,600 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-26 06:24:04
合計ジャッジ時間 5,530 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,880 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 8 ms
6,940 KB
testcase_06 AC 10 ms
6,940 KB
testcase_07 AC 11 ms
6,940 KB
testcase_08 AC 6 ms
6,944 KB
testcase_09 AC 12 ms
6,944 KB
testcase_10 AC 9 ms
6,944 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

ll num(ll n){
    ll N=n;
    ll val=1;
    for(ll i=2;i<=n;i++){
        ll cnt=0;
        if(n%i==0){
            while(n%i==0){
                n/=i;
                cnt++;
            }
        }
        val*=cnt+1;
        if(n==1) break;
    }
    return val;
}

int main()
{
    ll x;
    cin >> x;
    ll min_dif=INF;
    for(ll i=1;i<=x/2;i++){
        min_dif=min(min_dif,abs(i-num(i)-((x-i)-num(x-i))));
    }
    for(ll i=1;i<=x;i++){
        if(abs(i-num(i)-((x-i)-num(x-i)))==min_dif){
            cout << i << " " << x-i << endl;
        }
    }
    return 0;
} 
0