Submission #20035

#TimeUsernameProblemLanguageResultExecution timeMemory
20035ainta로봇 (kriii4_F)C++98
4 / 100
617 ms1084 KiB
#include<stdio.h> long long L,M,R, Res, Mod = 1000000007; int n, dx[4]={1,0,-1,0},dy[4]={0,-1,0,1}; long long Pow(long long a, long long b){ long long r = 1; while(b){ if(b%2)r=r*a%Mod; a=a*a%Mod;b/=2; } return r; } void Do(int pv, int x, int y, int dir, long long g){ if(pv==n){ Res = (Res+(x*x+y*y)*g)%Mod; return; } Do(pv+1,x+dx[dir],y+dy[dir],dir,g*M%Mod); Do(pv+1,x+dx[(dir+3)%4],y+dy[(dir+3)%4],(dir+3)%4,g*L%Mod); Do(pv+1,x+dx[(dir+1)%4],y+dy[(dir+1)%4],(dir+1)%4,g*R%Mod); } int main(){ scanf("%d%lld%lld%lld",&n,&L,&M,&R); if(n>15)return 0; Do(0,0,0,0,1); printf("%lld\n",Res*Pow(Pow((L+M+R)%Mod,Mod-2),n)%Mod); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...