結果

問題 No.1006 Share an Integer
ユーザー kikagekikage
提出日時 2020-04-11 04:53:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 892 ms
コンパイル使用メモリ 60,848 KB
実行使用メモリ 18,976 KB
最終ジャッジ日時 2023-10-17 09:09:59
合計ジャッジ時間 3,157 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 40 ms
12,052 KB
testcase_12 AC 87 ms
17,920 KB
testcase_13 AC 95 ms
18,724 KB
testcase_14 AC 96 ms
18,976 KB
testcase_15 AC 74 ms
16,668 KB
testcase_16 AC 29 ms
9,744 KB
testcase_17 AC 40 ms
12,052 KB
testcase_18 AC 76 ms
16,668 KB
testcase_19 AC 66 ms
16,140 KB
testcase_20 AC 79 ms
17,196 KB
testcase_21 AC 97 ms
18,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> d(N+1,0);
    vector<int> FA_B(N);
    int cmin=N;
    for(int i=1;i<=N;i++){
        for(int k=i;k<=N;k+=i)d[k]++;
    }
    for(int A=1;A<N;A++){
        FA_B[A]=abs(A-d[A]-(N-A)+d[N-A]);
        cmin=min(cmin,FA_B[A]);
    }
    for(int A=1;A<N;A++){
        if(FA_B[A]==cmin)cout << A << " " << N-A << endl;
    }
    return 0;
}
0