結果

問題 No.1006 Share an Integer
ユーザー totori_nyaatotori_nyaa
提出日時 2020-03-06 22:10:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 172,684 KB
実行使用メモリ 126,208 KB
最終ジャッジ日時 2024-04-22 08:03:23
合計ジャッジ時間 4,817 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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 AC 111 ms
71,996 KB
testcase_12 AC 210 ms
119,424 KB
testcase_13 AC 219 ms
126,208 KB
testcase_14 AC 224 ms
126,208 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 172 ms
109,440 KB
testcase_19 AC 164 ms
104,832 KB
testcase_20 AC 179 ms
112,584 KB
testcase_21 AC 200 ms
125,792 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(2*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