牛客-21愚人节-G-诡异的七重咒印
链接:https://ac.nowcoder.com/acm/contest/12800/G
思路:
输入num
1 2 3 4 5 6 7 8………………num
1 3 5 7 9 11 13………………2num-1
1 4 9 16 25 36 49………………numnum
1 2 4 8 16 32………………2^num
2 4 16 256 65536………………22num
1 2 1 2 1 2 1 2 1 2…………1||2
1 11 111 1111 11111 111111…………1(num)
代码:
#include<bits/stdc++.h>
using namespace std;
using intl=long long ;
const intl m=(intl)1e9+7;
intl ksm(intl a,intl b,intl mod){//快速幂
intl ans=1%mod;
a%=mod;
for(;b;b>>=1){
if(b&1){ans=ans*a%mod;}
a=a*a%mod;
}
return ans%mod;
}
int main (){
intl num;
cin>>num;
cout<<(num%m)<<endl;
cout<<(2*num%m-1+m)%m<<endl;
cout<<1LL*(num%m)*(num%m)%m<<endl;
cout<<ksm(2,num-1,m)<<endl;
cout<<ksm(2,ksm(2,num-1,m-1),m)<<endl;
cout<<((num&1)? 1:2)<<endl;
cout<<(ksm(10,num,m)-1+m)%m*(ksm(9,m-2,m))%m<<endl;
return 0;
}

浙公网安备 33010602011771号