結果

問題 No.1006 Share an Integer
ユーザー ngtkanangtkana
提出日時 2020-03-07 17:56:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 483 bytes
コンパイル時間 1,450 ms
コンパイル使用メモリ 166,040 KB
実行使用メモリ 18,984 KB
最終ジャッジ日時 2024-04-23 04:53:01
合計ジャッジ時間 2,951 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 42 ms
12,004 KB
testcase_12 AC 86 ms
18,036 KB
testcase_13 AC 88 ms
18,984 KB
testcase_14 AC 90 ms
18,816 KB
testcase_15 AC 71 ms
16,560 KB
testcase_16 AC 33 ms
9,808 KB
testcase_17 AC 44 ms
12,332 KB
testcase_18 AC 72 ms
16,700 KB
testcase_19 AC 68 ms
16,376 KB
testcase_20 AC 75 ms
17,208 KB
testcase_21 AC 90 ms
18,780 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=0;i<=X;i++){
        if(b.at(i)==min){
            std::cout<<i<<" "<<X-i<<std::endl;
        }
    }
}

0