結果

問題 No.1006 Share an Integer
ユーザー ShibuyapShibuyap
提出日時 2020-03-06 21:32:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 778 bytes
コンパイル時間 1,363 ms
コンパイル使用メモリ 162,684 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-22 05:09:23
合計ジャッジ時間 4,838 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
7,424 KB
testcase_01 AC 31 ms
7,508 KB
testcase_02 AC 30 ms
7,424 KB
testcase_03 AC 30 ms
7,552 KB
testcase_04 AC 30 ms
7,360 KB
testcase_05 AC 31 ms
7,424 KB
testcase_06 AC 30 ms
7,448 KB
testcase_07 AC 30 ms
7,424 KB
testcase_08 AC 31 ms
7,552 KB
testcase_09 AC 30 ms
7,424 KB
testcase_10 AC 31 ms
7,552 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 32 ms
7,512 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 1000005

int f[MAX_N];

int main() {
    int x;
    cin >> x;

    srep(i,1,MAX_N){
        srep(j,1,10000000){
            if(i * j >= MAX_N)break;
            f[i*j]++;
        }
    }

    int mi = 1001001001;
    srep(i,1,x){
        int j = x - i;
        mi = min(mi, abs(i - f[i] - (j - f[j])));
    }

    srep(i,1,x){
        int j = x - i;
        if(abs(i - f[i] - (j - f[j])) == mi){
            cout << i << ' ' << j << endl;
        }
    }
    
    return 0;
}
 
 
0