JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat  | Threaded  | Tree Previous Thread  |  Next Thread Forums Tutorial Discussions Dynamic Programming: From novice to advanced getting WA in IPL1
 getting WA in IPL1 | Reply I am getting WA in this question..http://www.spoj.com/problems/IPL1/pls hlp..here is my code...#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include using namespace std;#define FOR(I,A,B) for(int I= (A); I<(B); ++I)#define REP(I,N) FOR(I,0,N)#define S(N) scanf("%d", &N)#define S_String(A) scanf("%s",A)#define SL(N) scanf("%ld", &N)#define SLL(N) scanf("%lld", &N)#define PR(N) printf("%d\n",N)#define PRL(N) printf("%ld\n",N)#define PRLL(N) printf("%lld\n",N)#define SPACE printf(" ")#define NEW_LINE printf("\n")typedef long long int LL;typedef vector VI;double dp[10][120][300];int runs,wickets,balls,target;void convert_over(string str){int overs=0,i=0,ball;while(str[i]!='.'){overs=10*overs+str[i]-'0';i++;}if(str[i]=='.'){ball=str[++i]-'0';}balls=6*overs+ball;}void convert_score(string str){int i=0;//bool flag=false;runs=0;wickets=0;while(str[i]!='/'){runs=10*runs+str[i]-'0';i++;}if(str[i]=='/'){wickets=10*wickets+str[++i]-'0';}}double recursion(int balls, int reqRuns, int wickets){if (reqRuns<=0)return 1;if (balls==120||wickets==10)return 0;if((int)dp[wickets][balls][reqRuns]>=0)return dp[wickets][balls][reqRuns];dp[wickets][balls][reqRuns]=(recursion(balls+1, reqRuns,wickets)+recursion(balls+1, reqRuns-1,wickets)+recursion(balls+1, reqRuns-2,wickets)+recursion(balls+1, reqRuns-3,wickets)+recursion(balls+1, reqRuns-4,wickets)+recursion(balls+1, reqRuns-5,wickets)+recursion(balls+1, reqRuns-6,wickets)+recursion(balls+1, reqRuns,wickets+1)+2*recursion(balls, reqRuns-1,wickets))/10;return dp[wickets][balls][reqRuns];}void convert_ans(string str){int i=0;string str1="";while(str[i]!='.'){str1=str1+str[i];i++;}if(str[i]=='.'){str1=str1+str[i];i++;str1=str1+str[i];i++;str1=str1+str[i];}cout<<>overs;convert_over(overs);// cout<<>score;convert_score(score);// cout<<>target;if(runs>=target){cout<<"100.00"<<<"0.00"<<<
 Subject Author Date getting WA in IPL1 imindrajit May 30, 2013 at 7:11 AM EDT
 Forums Tutorial Discussions Dynamic Programming: From novice to advanced getting WA in IPL1 Previous Thread  |  Next Thread