Submission #1179785
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define int long long const int dx[]={1,-1,0,0}; const int dy[]={0,0,1,-1}; int N,D,X,Y,r; int memo[100][100][100]; double dfs(int count,int nowX,int nowY){ double ret=0.0; if(memo[count][nowX][nowY]>0)return memo[count][nowX][nowY]; if(count==N&& nowX==X && nowY==Y)return 1.0; else if(count==N)return 0.0; for(int i=0;i<4;i++){ ret+=dfs(count+1,nowX+dx[i],nowY+dy[i]); } memo[count][nowX][nowY]=ret; return memo[count][nowX][nowY]; } int pow(int x,int y){ if(y==0)return 1; if(y==1)return x; int res=1; while(y){ if(y&1)res*=x; x=x*x; y>>=1; } return res; } signed main(){ //N<=30 で解いてみる cin>>N>>D>>X>>Y; if(X%D!=0 || Y%D!=0){ cout<<0.0<<endl; return 0; } X/=D;Y/=D; //配列が負になるので+50 X+=N;Y+=N; cout<<dfs(0,N,N)/pow(4,N)<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 経路 |
User | albicilla |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 972 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample01.txt, sample02.txt |
All | 00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample01.txt, sample02.txt, sample01.txt, sample02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00.txt | WA | 1 ms | 256 KB |
01.txt | WA | 1 ms | 256 KB |
02.txt | WA | 1 ms | 256 KB |
03.txt | WA | 1 ms | 256 KB |
04.txt | WA | 1 ms | 256 KB |
05.txt | WA | 1 ms | 256 KB |
06.txt | WA | 1 ms | 256 KB |
07.txt | WA | 1 ms | 256 KB |
08.txt | WA | 1 ms | 256 KB |
09.txt | WA | 1 ms | 256 KB |
10.txt | WA | 1 ms | 256 KB |
11.txt | WA | 1 ms | 256 KB |
12.txt | WA | 1 ms | 256 KB |
13.txt | WA | 1 ms | 256 KB |
14.txt | WA | 1 ms | 256 KB |
15.txt | WA | 1 ms | 256 KB |
16.txt | WA | 1 ms | 256 KB |
17.txt | WA | 1 ms | 256 KB |
18.txt | WA | 1 ms | 256 KB |
19.txt | WA | 1 ms | 256 KB |
sample01.txt | WA | 1 ms | 256 KB |
sample02.txt | WA | 1 ms | 256 KB |