一直90分
查看原帖
一直90分
239832
sipu6174楼主2020/10/6 21:21

思路跟题解一样,就是(2p1)(l24)(2^p-1)(\lfloor \frac{l^2}{4} \rfloor).

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll T,n,m;
int main(){
   ios::sync_with_stdio(0);
   cin>>T;
   while(T--){
      cin>>n>>m;
      if(n==1){puts("0");continue;}
      while(n&(n-1)) n&=n-1;
      cout<<(n*2-1)%mod*(m*m/4)%mod<<'\n';
   }
   return 0;
}
2020/10/6 21:21
加载中...