提交时间:2022-08-08 11:33:28

运行 ID: 54951

#include <iostream> #include <cmath> #include <cstdio> using namespace std; int main() { // freopen("line.in","r",stdin); // freopen("line.out","w",stdout); int T; cin>>T; for (int i=0;i<T;i++) { int m,n; cin>>m>>n; long long total=(m+n)*pow(2,m+n-1)/2; if (m<=1) { cout<<total<<endl; continue; } long long girls=(n+1)*pow(2,m-1); long long res=total-girls; cout<<res<<endl; } return 0; }