由于有个奇妙的限制
所以
一定是一个小于的小数
加上这个东西
一定是整数
这个形式可以矩乘优化
最后把小数影响减去即可
#include<bits/stdc++.h>
using namespace std;
const int RLEN=1<<20|1;
inline char gc(){
static char ibuf[RLEN],*ib,*ob;
(ob==ib)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
return (ob==ib)?EOF:*ib++;
}
inline int read(){
char ch=gc();
int res=0,f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
#define ll unsigned long long
inline ll readl(){
char ch=gc();
ll res=0;bool f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
#define re register
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define cs const
#define bg begin
#define poly vector<int>
template<class T>inline void chemx(T &a,T b){a<b?a=b:0;}
template<class T>inline void chemn(T &a,T b){a>b?a=b:0;}
cs ll mod=7528443412579576937;
inline ll add(ll a,ll b){return a+b>=mod?a+b-mod:a+b;}
inline void Add(ll &a,ll b){a+=b;a>=mod?a-=mod:0;}
inline ll mul(ll a,ll b){return (a*b-(ll)((long double)a/mod*b)*mod+mod)%mod;}
ll d,b,n;
struct mat{
ll a[2][2];
mat(){memset(a,0,sizeof(a));}
friend inline mat operator *(cs mat &a,cs mat &b){
mat c;
for(int i=0;i<2;i++)
for(int k=0;k<2;k++)
for(int j=0;j<2;j++){
Add(c.a[i][j],mul(a.a[i][k],b.a[k][j]));
}
return c;
}
}tmp;
int f[100];
int main(){
b=readl(),d=readl(),n=readl();
if(n==0)return cout<<1,0;
if(n==1)return cout<<b,0;
tmp.a[0][0]=b,tmp.a[1][0]=(d-b*b)/4,tmp.a[0][1]=1;
mat res=tmp;
n-=2;
for(ll b=n;b;tmp=tmp*tmp,b>>=1)if(b&1)res=res*tmp;
ll ans=add(mul(res.a[0][0],b),mul(res.a[1][0],2));
if((n%2==0)&&(b*b!=d))ans--;
cout<<ans;
}