Submission #1771485


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)    //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
typedef long long LL;
typedef unsigned int UINT;
typedef pair<int, int> P;
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(UINT *a){scanf("%u",a);}                            //scan for type unsigned int
void SCAN(UINT *a,int n){int i;REP(i,n){scanf("%u",&a[i]);}}  //scan for type unsigned int array
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){int i;REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int MOD = 1000000007;
const int INF = 1999999999;
const LL INFLL = 999999999999999;

const int DX4[4]= {-1,0,1,0};
const int DY4[4]= {0,-1,0,1};

//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
	fill((T*)array,(T*)(array+N),val);
}
 
int pascalTri(int n,int r){
	int tri[n+1][n+1];
	int i,j;
	REP(i,n+1){REP(j,n+1){tri[i][j]=0;}}
	REP(i,n+1){
		REP(j,n+1){
			if(j>i){break;}
			if(j==0||j==i){tri[i][j]=1;}else{tri[i][j]=(tri[i-1][j-1]%MOD+tri[i-1][j]%MOD)%MOD;}
		}
	}
	return tri[n][r];
}

int n,d,x,y;
int dp[1005][2010][2010];

int dfs(int count,int nx,int ny){
	if(dp[count][nx][ny]!=INF){return dp[count][nx][ny];}
	if(count==n){
		if(nx==x&&ny==y){
			return 1;
		}else{
			return 0;
		}
	}

	int ans=0;
	REP(i,4){
		ans+=dfs(count+1,nx+DX4[i],ny+DY4[i]);
	}

	return dp[count][nx][ny]=ans;

}


int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	int a,b,c;
	int i,j;

	SCAN(&n);SCAN(&d);SCAN(&x);SCAN(&y);

	FILL(dp,INF);
	if(x%d!=0||y%d!=0){
		printf("0.0\n");
		return 0;
	}
	x/=d;y/=d;

	double cnt;
	cnt=pow(4,n);
	cnt=(double)dfs(0,0,0)/cnt;


	printf("%.10f\n",cnt);

	return 0;
}

Submission Info

Submission Time
Task D - 大ジャンプ
User nabe12
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2747 Byte
Status CE

Compile Error

./Main.cpp: In function ‘void SCAN(int*)’:
./Main.cpp:16:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void SCAN(int *a){scanf("%d",a);}                             //scan for type int
                                ^
./Main.cpp: In function ‘void SCAN(int*, int)’:
./Main.cpp:17:57: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
                                                         ^
./Main.cpp: In function ‘void SCAN(UINT*)’:
./Main.cpp:18:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void SCAN(UINT *a){scanf("%u",a);}                            //scan for type unsigned int
                                 ^
./Main.cpp: In function ‘void SCAN(UINT*, int)’:
./Main.cpp:19...