結果

問題 No.1006 Share an Integer
ユーザー 👑 tatyam
提出日時 2020-03-03 12:36:57
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 942 bytes
コンパイル時間 10,929 ms
コンパイル使用メモリ 276,644 KB
最終ジャッジ日時 2025-01-09 04:14:40
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; }
using uint = unsigned;
int f(uint N){
    uint d=0,sq=sqrt(N);
    for(uint i=2;i<=sq;i++){
        if(N%i==0){
            if(N/i==i)d++;
            else d+=2;
        }
    }
    return N-d;
}
int main()
{
    uint X;
    scanf("%u", &X);
    uint mid = X / 2;
    constexpr uint width = 119;
    uint mindif = X;
    vector<uint> ans;
    ans.reserve(8);
    for(uint A = mid; A && A + width > mid; A--){
        uint a = abs(f(A) - f(X - A));
        if(chmin<uint>(mindif, a)) ans.clear();
        if(mindif == a) ans.push_back(A);
    }
    for(uint i = ans.size(); i--; ) printf("%u %u\n", ans[i], X - ans[i]);
    for(uint i = mid * 2 == X; i < ans.size(); i++) printf("%u %u\n", X - ans[i], ans[i]);
}
0