#include <stdio.h>
long MOD = 12357;
long N;
long a[5];
void solve()
{
int i = 0;
a[0] = 0;
a[1] = 2;
a[2] = 3;
for (i = 3; i <= N; i++)
{
if (i & 1)
{
a[i%5] = (2*a[(i-1+5)%5] + a[(i-2+5)%5]) % MOD;
}
else
{
a[i%5] = (3*a[(i-2+5)%5] + a[(i-3+5)%5]) % MOD;
}
}
if (N & 1)
{
printf("0\n");
}
else
{
printf("%ld\n",a[N%5]);
}
}
int main()
{
scanf("%ld",&N);
solve();
return 0;
}
时间: 2025-01-01 14:02:10