| Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|
| 81222 | sh25_zhuwy | 格雷码 | C++ | Accepted | 1 MS | 256 KB | 499 | 2026-01-04 15:42:19 |
#include<bits/stdc++.h> using namespace std; unsigned long long g(int a,int b){ unsigned long long ans=1; for(int i=1;i<=b;++i){ ans*=a; } return ans; } string f(int n,unsigned long long k){ if(n==1){ if(k){ return "1"; }else{ return "0"; } }else{ if(k<g(2,n-1)){ return "0"+f(n-1,k); }else{ return "1"+f(n-1,g(2,n)-k-1); } } } int main(){ int n; unsigned long long k; cin>>n>>k; cout<<f(n,k); return 0; }