Codeforces Round #420 (Div. 2), problem: (E) Okabe and El Psy Kongroo Solution In C/C++

#include <stdio.h>
#define m 1000000007u
typedef long long unsigned llu;
typedef unsigned u;
u M[16][64][16][16];
u X[16],Y[16],*A,*B,*C;
int main()
{
u q,n,e,i,j,k;
for(n=-1;++n<16;)
{
for(i=-1;++i<=n;)
for(j=-1;++j<=n;)
M[n][0][i][j]=(i<j?j-i:i-j)<2;
for(e=0;++e<64;)
{
for(i=-1;++i<=n;)
for(j=-1;++j<=n;)
for(k=-1;++k<=n;)
M[n][e][i][j]=
(
M[n][e][i][j]+
M[n][e-1][i][k]*
(llu)M[n][e-1][k][j]
)%m;
}
}
llu x,y,z;*(A=X)=1;B=Y;
for(scanf(“%u%I64u”,&q,&z);q–;)
{
scanf(“%I64u%I64u%u”,&x,&y,&n);
if(y>z)y=z;
for(x=y-x,e=0;x;x>>=1,++e)if(x&1)
{
for(i=-1;++i<=n;)
for(B[i]=0,j=-1;++j<=n;)
B[i]=(B[i]+M[n][e][i][j]*(llu)A[j])%m;
C=A;A=B;B=C;
}
for(i=n;++i<16;)A[i]=0;
}
printf(“%u\n”,*A);
return 0;
}

Hello World from Antigravity...

Hello World! This blog post was automatically created and published...

Why Closet Organization Tools...

📢 As an Amazon Associate, I earn from qualifying...

Everything Discussed During The...

Strategy game publisher and developer Slitherine recently hosted its...

Everything You Need to...

📢 As an Amazon Associate, I earn from qualifying...

Russ Allbery: Review: Radiant...

Science fiction enthusiasts and literary critics alike are turning...

Why Pet Travel Gear...

📢 As an Amazon Associate, I earn from qualifying...

Hello World from Antigravity IDE

Hello World! This blog post was automatically created and published directly from Antigravity IDE using the WordPress REST API!

Why Closet Organization Tools Is Currently Breaking the Internet

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...

Everything Discussed During The Slitherine Next 2026 Event

Strategy game publisher and developer Slitherine recently hosted its dedicated digital showcase, Slitherine Next 2026, delivering an action-packed presentation tailored specifically for tactics enthusiasts...

Everything You Need to Know About Rechargeable Home Tech Right Now

📢 As an Amazon Associate, I earn from qualifying purchases.I stumbled across this while desperately trying to fix a recurring problem in my routine....

Russ Allbery: Review: Radiant Star

Science fiction enthusiasts and literary critics alike are turning their eyes toward the upcoming release of Radiant Star, the latest novel by award-winning author...

Why Pet Travel Gear Is Currently Breaking the Internet

📢 As an Amazon Associate, I earn from qualifying purchases.After putting the Pet Travel Gear through a proper 30-day real-world test, I can tell...

Mall Together-TENOKE

Simulation gaming enthusiasts have a fresh operational challenge to tackle with the arrival of Mall Together-TENOKE. This brand-new release delivers an immersive shopping mall...

7 Reasons This Coffee Bar Accessories Is Worth Every Single Penny

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

Why Kitchen Organization Tools Is Currently Breaking the Internet

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...