結果

問題 No.1006 Share an Integer
ユーザー totori_nyaatotori_nyaa
提出日時 2020-03-06 21:45:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 647 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 164,684 KB
実行使用メモリ 17,460 KB
最終ジャッジ日時 2024-04-22 06:09:52
合計ジャッジ時間 7,909 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    int x[n+1]={};
    for(int val=1;val<=n;val++){
        int ret = 0;
        for(int i=1;i*i<=val;i++){
            if(val%i==0)ret++;
            if(val%i==0 && i*i!=val)ret++;
        }
        x[val] = val-ret;
    }
    int ans = 11111110;
    for(int i=1;i<n;i++){
        ans = min(ans,abs(x[i]-x[n-i]));
    }
    for(int i=1;i<n;i++){
        if(abs(x[i]-x[n-i]) == ans){
            cout << i << " " << n-i << "\n";
        }
    }
    
}
0