1 solutions

  • 0
    @ 2025-9-24 19:01:54
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	//if(n==pow(2,x)+pow(2,y))
    	int l,r;
    	cin>>l>>r;
    	int ans=0;//表示幂和数的个数 
    	for(int n=l;n<=r;n++) //一定先有n,再有(x,y)保证(n)只出现一次 
    	{
    		int cnt=0;//表示当前pow(2,x)+pow(2,y)==n的个数
    		for(int x=0;pow(2,x)<=n;x++)
    		{
    			for(int y=0;pow(2,y)<=n;y++)
    			{
    				if(pow(2,x)+pow(2,y)==n)
    				{
    					cnt++; //说明多了一组pow(2,x)+pow(2,y)==n, 
    				}
    			}
    		} 
    		if(cnt!=0) //说明至少存在一组x,y满足幂和数的条件 
    		{
    			ans++;
    		}
    	}
    	cout<<ans;
    	return 0;
    }
    
    
    
    
    • 1

    Information

    ID
    2806
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    # Submissions
    28
    Accepted
    7
    Uploaded By