Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:物理课上着上着就想到错哪儿了,别这么低级了啊!!!位运算看不懂的话就看我这个吧。。。In Reply To:物理课上着上着就想到错哪儿了,别这么低级了啊!!!位运算看不懂的话就看我这个吧。。。 Posted by:ltj_njust at 2010-11-02 12:53:52 > #include<iostream> > using namespace std; > > int solve(int a){ > int count=0,i=2; > while(i<=a){ > count+=a/i; > i=i*2;//这个地方我昨晚写的是i=i*i,小悲剧,害我wa两次 > } > return count; > } > int main(){ > int n,k; > while(cin>>n&&cin>>k){ > if(k==0||k==n){ > cout<<"1"<<endl; > continue; > } > if(solve(n)==solve(k)+solve(n-k)){ > cout<<"1"<<endl; > continue; > } > cout<<"0"<<endl; > } > return 0; > } > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator