救救孩子吧快死了

P1362 兔子数

十重循环!!!~~火速逃离案发现场~~
by _Haoomff_ @ 2022-04-21 18:05:23


@[ZLTZLT](/user/555381) 有两个 `l` 变量名,一个在循环里,一个是输入的数据。
by Terrible @ 2022-04-21 18:35:10


```cpp #include <bits/stdc++.h> using namespace std; #define int long long int L,R,s,ans; inline int rabbit(int n){ int sum=0; while(n){ sum+=n%10; n/=10; } return sum; } signed main(){ cin>>L>>R; for(int i=0;i<=3;++i){ for(int j=0;j<=3;++j){ for(int k=0;k<=3;++k){ for(int l=0;l<=3;++l){ for(int x=0;x<=3;++x){ for(int y=0;y<=3;++y){ for(int z=0;z<=3;++z){ for(int a=0;a<=3;++a){ for(int b=0;b<=3;++b){ for(int c=0;c<=3;++c){ s=i*1e8+j*1e7+k*1e6+l*1e5+x*1e4+y*1e3+z*1e2+a*10+b+c*1e9; if(s<L||s>R) continue; if(rabbit(s)*rabbit(s)==rabbit(s*s)){ ++ans; } } } } } } } } } } } cout<<ans; return 0; } ```
by peterwuyihong @ 2022-04-21 18:36:52


谢谢大佬orz
by zlttcl @ 2022-04-21 18:40:45


~~注意到兔子数的各位数都不超过3 然后dfs一下~~
by hyf9134 @ 2022-05-11 22:17:18


|