結果
問題 | No.1006 Share an Integer |
ユーザー |
![]() |
提出日時 | 2020-03-06 21:52:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 148 ms / 2,000 ms |
コード長 | 671 bytes |
コンパイル時間 | 2,724 ms |
コンパイル使用メモリ | 192,656 KB |
最終ジャッジ日時 | 2025-01-09 05:03:22 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //INSERT ABOVE HERE const Int MAX = 2e6+100; Int cnt[MAX]={}; Int calc(Int a,Int b){ return abs((a-cnt[a])-(b-cnt[b])); } signed main(){ cin.tie(0); ios::sync_with_stdio(0); for(Int i=1;i<MAX;i++) for(Int j=i;j<MAX;j+=i) cnt[j]++; Int x; cin>>x; Int res=MAX; for(Int a=1;a<x;a++) chmin(res,calc(a,x-a)); for(Int a=1;a<x;a++) if(calc(a,x-a)==res) cout<<a<<" "<<x-a<<"\n"; cout<<flush; return 0; }