80分代码求优化

P5657 [CSP-S2019] 格雷码

@[Unaccepted_zero](/user/242619) 改cin然后过了
by Charser茶色 @ 2019-11-20 22:04:50


@[Charser茶色](/user/148184) cin就耗时长,其他的很靠谱
by GalilAR @ 2019-11-20 22:11:29


@[Charser茶色](/user/148184) ull是用%llu的
by minstdfx @ 2019-11-20 22:25:18


@[Unaccepted_zero](/user/242619) 你在误人子弟吗。。。?哪里来的大写LLd
by ZYyboT @ 2019-11-20 22:54:38


``` scanf("%d%llu",&n,&k); ```
by Yuanchenpu @ 2019-11-20 23:07:13


@[Unaccepted_zero](/user/242619) 突然发现还没过,最后一个点不行 代码: ```cpp #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; unsigned long long pand(int n){ unsigned long long sum=1; for(int i=1;i<n;i++) sum*=2; return sum; } void dfs(int n,unsigned long long k){ if(n==0) return; unsigned long long x=pand(n); if(k>x) { printf("1"); dfs(n-1,x-k+1+x); } else { printf("0"); dfs(n-1,k); } } int main(){ int n; unsigned long long k; scanf("%d%llu",&n,&k); dfs(n,k+1); return 0; } ```
by Charser茶色 @ 2019-11-21 20:38:02


上一页 |