結果
問題 | No.1006 Share an Integer |
ユーザー | hanbei_dayo |
提出日時 | 2020-07-26 12:00:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 124 ms / 2,000 ms |
コード長 | 1,063 bytes |
コンパイル時間 | 806 ms |
コンパイル使用メモリ | 97,576 KB |
実行使用メモリ | 19,232 KB |
最終ジャッジ日時 | 2023-09-10 20:16:11 |
合計ジャッジ時間 | 5,772 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 116 ms
18,984 KB |
testcase_01 | AC | 116 ms
18,904 KB |
testcase_02 | AC | 115 ms
19,228 KB |
testcase_03 | AC | 115 ms
19,096 KB |
testcase_04 | AC | 113 ms
19,172 KB |
testcase_05 | AC | 114 ms
18,908 KB |
testcase_06 | AC | 113 ms
19,092 KB |
testcase_07 | AC | 114 ms
18,908 KB |
testcase_08 | AC | 120 ms
18,972 KB |
testcase_09 | AC | 116 ms
18,968 KB |
testcase_10 | AC | 116 ms
19,032 KB |
testcase_11 | AC | 117 ms
18,972 KB |
testcase_12 | AC | 124 ms
18,972 KB |
testcase_13 | AC | 122 ms
18,988 KB |
testcase_14 | AC | 118 ms
18,916 KB |
testcase_15 | AC | 121 ms
18,912 KB |
testcase_16 | AC | 118 ms
18,908 KB |
testcase_17 | AC | 119 ms
18,976 KB |
testcase_18 | AC | 120 ms
19,172 KB |
testcase_19 | AC | 123 ms
19,100 KB |
testcase_20 | AC | 121 ms
19,232 KB |
testcase_21 | AC | 122 ms
18,988 KB |
ソースコード
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<utility> #include<map> #include<set> #include<queue> #include<stack> #include<functional> #include<math.h> #include<random> #include <bitset> using namespace std; #define N (1000000000+7) //#define N 998244353 #define INF 1e16 typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> Q; const int inf = (int)1e9; ll gcd(ll a, ll b) { if (b > a) { ll tmp = b; b = a; a = tmp; } if (a%b == 0)return b; else return gcd(b, a%b); } ll inv(ll x,ll power) { ll res = 1; ll k = power; ll y = x%N; while (k) { if (k & 1)res = (res*y) % N; y = (y%N*y%N) % N; k /= 2; } return res; } ll d[2000100]; int main(void){ for(ll i=1;i<=2000000;i++){ d[i]++; for(ll j=2;i*j<=2000000;j++)d[i*j]++; } ll X; cin>>X; ll Min = 1000000000; for(ll i=1;i<=X-1;i++){ ll m = i-d[i]-(X-i-d[X-i]); if(m<0)m*=-1; if(Min>m)Min = m; } for(ll i=1;i<=X-1;i++){ ll m = i-d[i]-(X-i-d[X-i]); if(m<0)m*=-1; if(Min==m)cout<<i<<" "<<X-i<<endl; } return 0; }