2 solutions

  • 3
    @ 2026-6-7 14:48:45
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int l,r;
    	cin>>l>>r;
    	int cnt=0;
    	for(int n=l;n<=r;n++)
    	{
    		//判断2^x+2^y==n  pow(a,b)=>a^b
    		int c=0;
    		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)
    				{
    					c=1;
    				}
    			}
    		}
    		if(c==1)
    		{
    			cnt++;
    		}
    	} 
    	cout<<cnt;
    	return 0;
    }
    
    
    • 1
      @ 2026-10-11 14:39:28
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
          int l,r;
          cin>>l>>r;
          int cnt = 0;
          for(int i=l;i<=r;i++){
              int flag = 0;
              for(int x = 0;x<=15;x++){
                  for(int y = 0;y<=15;y++){
                      if(i==pow(2,x)+pow(2,y)){
                          flag= 1;
                      }
                  }
              }
              if(flag == 1) cnt++;
          }
          cout<<cnt;
      return 0;
      }
      
      • 1

      Information

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