F-Sumo and Luxury Car 补题

F-Sumo and Luxury Car

As we all know, Sumo has a lot of luxury cars, Maserati, Porsche, Lincoln, and so on. Countless cars are parked in his garage. He is worried about what kind of car he drives every day. Can you help him?

Sumo has a total of n cars. Every day, he will choose any number of cars from the n cars (the number of cars cannot be 0) to form a team, and then choose one from this team to drive himself. How many options are there?

If the selected team set is different or the car he chooses is different, it is considered to be two different plans.
输入描述:
The first line of the input is a single integer T(1 \leq T \leq 10)T(1≤T≤10)which is the number of test cases. T test cases follow.

Each test case has a single integer n(1 \leq n \leq 10^9)n(1≤n≤10
9
), representing the total number of luxury cars in Sumo.
输出描述:
For each test case, print a single line containing an integer modulo 10^9+710
9
+7.
示例1
输入
复制
2
1
2
输出
复制
1
4
备注:
In the second sample, Sumo has four situations to drive:
Choose cars with numbers 1 and 2, drive the car with number 1,
Choose cars with numbers 1 and 2, drive the car with number 2,
Choose the car with numbers 1, drive the car with number 1,
Choose the car with numbers 2, drive the car with number 2.
So the answer is 4.
这个一开始以为是排列组合的问题,结果。。。。。。
不多说了,反正就是没做出来-_-

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod=1e9+7;
ll qpow(ll x,ll n)
{
    ll sum=1;
    while(n)
    {
        if(n%2==1)//if(n&1)
            sum=(sum*x)%mod;
        x=(x*x)%mod;
        n>>=1;//n=n/2;
    }
    return sum;
}
int main()
{
    long long int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        cout<<qpow(2,n-1)*n%mod<<endl;
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值