結果
問題 |
No.690 E869120 and Constructing Array 4
|
ユーザー |
![]() |
提出日時 | 2024-10-24 12:15:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 2,490 bytes |
コンパイル時間 | 1,441 ms |
コンパイル使用メモリ | 118,316 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-24 12:15:46 |
合計ジャッジ時間 | 3,080 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <assert.h> #include <ctype.h> #include <errno.h> #include <float.h> #include <limits.h> #include <locale.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <wchar.h> #include <wctype.h> #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <exception> #include <fstream> #include <functional> #include <limits> #include <list> #include <map> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <utility> #include <vector> #include <cwchar> #include <cwctype> #include <random> #include <complex.h> #include <fenv.h> #include <inttypes.h> #include <stdbool.h> #include <stdint.h> #include <tgmath.h> #include <forward_list> #include <unordered_set> #include <unordered_map> using namespace std; typedef long long ll; typedef unsigned long long ull; const int maxn=1e3+7; int vis[maxn][maxn]; vector<int> a,b; int main() { cin.tie(0); cout.tie(0); std::ios::sync_with_stdio(false); // FILE *fsd=fopen("seed.txt","r"); // unsigned int sd,mhm578; // fscanf(fsd,"%u%u",&sd,&mhm578); // FILE *gsd=fopen("seed.txt","w"); // sd+=114514,mhm578+=1; // fprintf(gsd,"%u\n%u\n",sd,mhm578); // mt19937 rnd(time(0)+sd); // freopen("wander.in","r",stdin); // freopen("wander.out","w",stdout); ll n; cin>>n; ll num; for(ll i=0ll;;i++) if((1ll<<i)>n) { num=i+1; break; } ll dian=num+1ll; // cout<<dian<<" "; ll bian=(dian)*(dian-1ll)/(2ll); ll d=(1ll<<(num-1ll))-n; // cout<<bian<<"\n"; // cout<<d<<"\n"; if(d==0ll) { cout<<dian<<" "<<bian<<"\n"; for(ll i=1ll;i<dian;i++) for(ll j=i+1ll;j<=dian;j++) cout<<i<<" "<<j<<"\n"; return 0; } for(ll i=num;i>=0;i--) { ll p=(1ll<<i); if(d>=p) { d-=p; vis[2+i][dian]=1; bian--; } } cout<<dian<<" "<<bian<<"\n"; for(int i=1ll;i<dian;i++) for(int j=i+1ll;j<=dian;j++) if(vis[i][j]==0) cout<<i<<" "<<j<<"\n"; return 0; }