結果

問題 No.1006 Share an Integer
ユーザー ngtkanangtkana
提出日時 2020-03-07 17:56:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 1,390 ms
コンパイル使用メモリ 165,112 KB
実行使用メモリ 18,820 KB
最終ジャッジ日時 2024-04-23 04:53:25
合計ジャッジ時間 2,893 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 45 ms
11,904 KB
testcase_12 AC 95 ms
18,176 KB
testcase_13 AC 106 ms
18,804 KB
testcase_14 AC 102 ms
18,820 KB
testcase_15 AC 79 ms
16,640 KB
testcase_16 AC 31 ms
9,912 KB
testcase_17 AC 44 ms
12,160 KB
testcase_18 AC 81 ms
16,792 KB
testcase_19 AC 71 ms
16,128 KB
testcase_20 AC 86 ms
17,152 KB
testcase_21 AC 98 ms
18,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
int main(){
    int X;std::cin>>X;
    std::vector<int>a(X+1);
    for(int i=1;i<=X;i++){
        for(int j=i;j<=X;j+=i){
            a.at(j)++;
        }
    }
    std::vector<int>b(X+1);
    for(int i=0;i<=X;i++){
        int j=X-i;
        b.at(i)=std::abs(i-a.at(i)-(j-a.at(j)));
    }
    int min=*std::min_element(b.begin(),b.end());
    for(int i=1;i<X;i++){
        if(b.at(i)==min){
            std::cout<<i<<" "<<X-i<<std::endl;
        }
    }
}

0