結果

問題 No.1006 Share an Integer
ユーザー logxlogx
提出日時 2020-03-15 00:40:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 618 bytes
コンパイル時間 1,333 ms
コンパイル使用メモリ 168,756 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-05-03 01:32:49
合計ジャッジ時間 5,244 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 4 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 8 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 7 ms
5,376 KB
testcase_09 AC 12 ms
5,376 KB
testcase_10 AC 10 ms
5,376 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;

int euler(int x){
    int ans=0;
    rep2(i,1,x+1){
        if(x%i==0)ans+=1;
    }
    return ans;
}

int main() {
    int x;cin >> x;
    int m=x;
    rep2(i,1,x/2){
        int k;
        k=2*i+euler(x-i)-euler(i)-x;
        if(k<0)k*=-1;
        m=min(m,k);
        if(m==0)break;
    }
    rep2(i,1,x){
        int k;
        k=2*i+euler(x-i)-euler(i)-x;
        if(k<0)k*=-1;
        if(k==m)cout << i << ' ' << x-i << endl;
    }
}
0