hdu 4704
题目大意:组成N的方法数
即
2n−1
% (1e9 + 7),即 (n - 1) % (1e9 + 6), n 位大数,分位计算,在使用快速幂。。。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#define LL __int64
#define MAX 0x3f3f3f3f
#define MOD (1000000000 + 7)
#define N (100000 + 5)
using namespace std;
char str[N];
LL qu_mod(LL a, LL b)
{
LL base = a, temp = 1;
while (b != 0)
{
if (b & 1)
{
temp *= base % MOD;
}
b >>= 1;
base *= base;
}
return temp % MOD;
}
int main()
{
while (~scanf("%s", str))
{
int len = strlen(str);
LL ans = 0;
for (int i = 0; i < len; i++)
{
ans = (ans * 10 + (str[i] - '0')) % (MOD - 1);
}
// cout << ans << endl;
ans = qu_mod(2, ans - 1);
printf("%I64d\n", ans);
}
}