zrq’s blogPE 405

好久没有写过PE了……

自己分析图形来推……
公式:$$f(n) = 1 + frac{1}{15} ((-1)^{n+1} - 20 cdot 2^n + 6 cdot 4^n)$$

【答案】237696125

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <cstdio>
using namespace std;
typedef long long LL;
const LL M = 410338673;
const LL phiM = 386201104;
LL (LL a,LL b,LL c)
{
LL ret = 1;
for (;b;b >>= 1,a = a * a % c)
if (b & 1) ret = ret * a % c;
return ret;
}
int main()
{
LL n = ksm(10,(LL)1e18,phiM);
LL ans = -1ll - 20ll * ksm(2,n,M) + 6ll * ksm(4,n,M);
ans = ans * ksm(15,phiM - 1,M) % M;
ans = (ans % M + M + 1) % M;
cout << ans << endl;
}