问题如下(附链接):穿越时空之门
题解代码如下:
#include <iostream>
using namespace std;
int x1(int i)
{
int a=0;
while(i)
{
a+=i%2;
i/=2;
}
return a;
}
int x2(int i)
{
int b=0;
while(i)
{
b+=i%4;
i/=4;
}
return b;
}
int main()
{
int ans=0;
for(int i=1;i<=2024;i++)
{
if(x1(i)==x2(i))
ans++;
}
cout<<ans<<'\n';
return 0;
}
标签:return,真题,int,题解,蓝桥,while,i%
From: https://blog.csdn.net/2401_87130535/article/details/142865539