# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
20035 | | ainta | 로봇 (kriii4_F) | C++98 | | 617 ms | 1084 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |