0
已解决
为啥错了?
#include<iostream>
using namespace std;
int f(int n)
{
if(n==0)return 0;
if(n==1)return 1;
if(n%2==0)return f(n/2);
else return f(n/2)+f(n/2+1);
}
int main(){
int s,n;
cin>>s;
for(int i=1;i<=s;i++)
{
cin>>n;
cout<<f(n)<<endl;
}
return 0;
}
WA30分。
1
已采纳
0
0
0
0
0
0
0
0