Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:物理课上着上着就想到错哪儿了,别这么低级了啊!!!位运算看不懂的话就看我这个吧。。。

Posted by liugf05 at 2011-11-15 23:18:41 on Problem 3219
In Reply To:物理课上着上着就想到错哪儿了,别这么低级了啊!!!位运算看不懂的话就看我这个吧。。。 Posted by:ltj_njust at 2010-11-02 12:53:52
> #include<iostream>
> using namespace std;
> 
> int solve(int64 a){
>     int64 count=0,i=2;
>     while(i<=a){
>         count+=a/i;
>         i=i*2;//这个地方我昨晚写的是i=i*i,小悲剧,害我wa两次
>     }
>     return count;
> }
> int main(){
>     int64 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator