結果
問題 |
No.2118 遺伝的有限集合の数え上げ
|
ユーザー |
![]() |
提出日時 | 2022-11-04 22:28:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 519 bytes |
コンパイル時間 | 2,169 ms |
コンパイル使用メモリ | 201,540 KB |
最終ジャッジ日時 | 2025-02-08 18:03:46 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; map<int,string> m; string dfs(int x){ bool b=false; string res="{"; rep(i,21){ if((1<<i)>x) break; if(x&(1<<i)){ if(b) res+=","; res+=dfs(i); b=true; } } res+="}"; return m[x]=res; }; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); m[0]="{}"; int n; cin>>n; cout<<dfs(n)<<'\n'; return 0; }