Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- typedef long long ll;
- using namespace std;
- ll pot(ll a, ll n) {
- if (n == 0) return 1;
- ll x = pot(a, n/2);
- if (n % 2 == 0) return (x*x)%((ll)1e9+7);
- return (x*x*a)%((ll)1e9+7);
- }
- int main() {
- ll t;
- cin>>t;
- while(t--){
- ll n;
- cin>>n;
- ll suma=0;
- for(ll i=1; i<=n; i++){
- suma=(suma%((ll)1e9+7)+pot(2,(n-i))*i%((ll)1e9+7))%((ll)1e9+7);
- }
- cout<<suma<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement