# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
20035 |
2016-02-25T08:46:45 Z |
ainta |
로봇 (kriii4_F) |
C++ |
|
617 ms |
1084 KB |
#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1084 KB |
Output is correct |
2 |
Correct |
0 ms |
1084 KB |
Output is correct |
3 |
Correct |
0 ms |
1084 KB |
Output is correct |
4 |
Correct |
22 ms |
1084 KB |
Output is correct |
5 |
Correct |
0 ms |
1084 KB |
Output is correct |
6 |
Correct |
0 ms |
1084 KB |
Output is correct |
7 |
Correct |
23 ms |
1084 KB |
Output is correct |
8 |
Correct |
0 ms |
1084 KB |
Output is correct |
9 |
Correct |
0 ms |
1084 KB |
Output is correct |
10 |
Correct |
67 ms |
1084 KB |
Output is correct |
11 |
Correct |
0 ms |
1084 KB |
Output is correct |
12 |
Correct |
0 ms |
1084 KB |
Output is correct |
13 |
Correct |
22 ms |
1084 KB |
Output is correct |
14 |
Correct |
0 ms |
1084 KB |
Output is correct |
15 |
Correct |
0 ms |
1084 KB |
Output is correct |
16 |
Correct |
22 ms |
1084 KB |
Output is correct |
17 |
Correct |
0 ms |
1084 KB |
Output is correct |
18 |
Correct |
0 ms |
1084 KB |
Output is correct |
19 |
Correct |
3 ms |
1084 KB |
Output is correct |
20 |
Correct |
0 ms |
1084 KB |
Output is correct |
21 |
Correct |
0 ms |
1084 KB |
Output is correct |
22 |
Correct |
0 ms |
1084 KB |
Output is correct |
23 |
Correct |
0 ms |
1084 KB |
Output is correct |
24 |
Correct |
0 ms |
1084 KB |
Output is correct |
25 |
Correct |
7 ms |
1084 KB |
Output is correct |
26 |
Correct |
0 ms |
1084 KB |
Output is correct |
27 |
Correct |
0 ms |
1084 KB |
Output is correct |
28 |
Correct |
5 ms |
1084 KB |
Output is correct |
29 |
Correct |
207 ms |
1084 KB |
Output is correct |
30 |
Correct |
617 ms |
1084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1080 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |