3973: 你看我像压轴题吗 =.=

3973: 你看我像压轴题吗 =.=

题目:

球球有一个口袋装有n个不一样的球。他向别人表演魔术时,每次可以从口袋中拿自己想要的球(至少拿一个)。
如果这样的话,本题还是比较简单(错了,是魔术容易被人看穿)球球在小周的指导下,球球开始厌恶1和n-1这两个数字。
因此球球不想取出的球总数是1个和n-1个,即她可取球的总数为(2,3,4,5,6......n-2,n)。
问他取一次球共有多少种取法?

输入
第一行一个t,代表测试样例组数。随后t行,每行输入一个n代表口袋球的个数。 
t<2000,0<n<1018 

输出
输出一行代表答案。请模20190809输出。

样例输入
1
5

样例输出
Case1: 21

代码:

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<fstream>
using namespace std;
typedef long long ll;
const ll mod = 20190809;
ll Pow(ll base, ll n){
    ll ans = 1;
    while(n > 0){
        if(n&1){
            ans = ans*base%mod;
        }
        base = base*base%mod;
        n = n>>1;
    }
    return ans%mod;
}
int main(){
    ll n, t, c = 1;
    scanf("%lld", &t);
//    ofstream in;
//    in.open("ans.txt");
    while(t--){
        scanf("%lld", &n);
        if(n == 1){
            printf("Case%lld: 0\n", c++);
//              in << "Case" << c++ << ": " << 0 << endl;
            continue;
        }
        if(n == 2){
            printf("Case%lld: 1\n", c++);
//              in << "Case" << c++ << ": " << 1 << endl;
            continue;
        }
        ll d = -1-2*n;
        d = (d%mod+mod)%mod;
        ll ans = Pow(2, n)+d;
        ans %= mod;
        printf("Case%lld: %lld\n", c++, ans%mod);
//        in << "Case" << c++ << ": " << ans << endl;
    }
//    in.close();
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值