結果

問題 No.1006 Share an Integer
ユーザー totori_nyaatotori_nyaa
提出日時 2020-03-06 22:07:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 739 bytes
コンパイル時間 1,781 ms
コンパイル使用メモリ 172,612 KB
実行使用メモリ 79,328 KB
最終ジャッジ日時 2024-04-22 07:56:55
合計ジャッジ時間 4,590 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 93 ms
45,756 KB
testcase_12 AC 180 ms
75,132 KB
testcase_13 AC 205 ms
79,292 KB
testcase_14 AC 191 ms
79,328 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 157 ms
68,944 KB
testcase_19 AC 147 ms
66,120 KB
testcase_20 AC 163 ms
70,892 KB
testcase_21 AC 184 ms
79,064 KB
権限があれば一括ダウンロードができます

ソースコード

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;
    vector<int> v(n+1,1);
    vector<vector<int>> ans(n+1);
    for(int i=2;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            v[j]++;
        }
        v[i] = i-v[i];
        if(i >= n-i){
            ans[abs(v[i]-v[n-i])].push_back(i);
            ans[abs(v[i]-v[n-i])].push_back(n-i);
        }
    }
    for(int i=0;i<=n;i++){
        if(ans[i].size()){
            sort(ans[i].begin(),ans[i].end());
            for(auto j:ans[i]){
                cout << j << " " << n-j << "\n";
            }
            return 0;
        }
    }
}
0