hamobos499's blog

By hamobos499, 5 weeks ago, In English,

Problem statement

Two friends Kunal and Satyam are playing an interesting game. They take turns drawing a ball from a bag which initially contains R red balls and G green balls. Each player draws a ball alternatively and never put it back. The person who is the first to draw a red balls wins. Satyam always draws first. If there are no more balls in the bag and nobody has drawn a red ball, the satyam wins.

Input -----

The first line will contain the number of test cases T. The first line of each test case will contain a number R (number of red balls) and G(number of green balls )

Cases:

2 1 --> 0.6666667 1 1 ---> 0.50000 10 0 ----> 1.0000

problem link is here:

I tired to solve the problem using top-bottom approach but my codes gives wrong answer at the last case (0 instead of 1)

int probability = 0, c = 0;

void magic(int red, int green, int turn){
	if(green == -1 || red == -1)return ;
	if(red == 0){
		probability++;
		if(turn % 2 == 0) c++;
		return ;
	}
	if(turn == -1) turn = 0;
	else turn++;
	magic(red, green-1, turn % 2);
	magic(red-1, green, turn % 2); 
	return ;
}

int main(){
     
 	ios::sync_with_stdio(0);
    cin.tie(nullptr);
     
    int q;
    cin >> q;
    while(q--){
    	int x, y;
    	cin >> x >> y;
    	magic(x, y, -1);
    	cout << fixed << setprecision(9) << c * 1.0 / probability << '\n';
    	probability = 0, c = 0;
    }
    return 0;
}

I will appreciate any kind of help from all of you, and thanks for your time

Read more »

Tags dp
 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By hamobos499, history, 6 weeks ago, In English,

When I enter my submission page and click in my submission IDs, It doesn't work with me, and so when I enter a problem like and click on my submissions the "Click here to see details" doesn't work too!

  • Another problem, I have submittied a problem called CME form yesterday and It got accepted at 31 ms and now I submitted the same exact code and got accepted at 46 ms!

Does someone else have the same Issue as mine?

Read more »

 
 
 
 
  • Vote: I like it
  • +6
  • Vote: I do not like it

By hamobos499, history, 3 months ago, In English,

Hi everyone,

This problem gives you two inputs N, M and N contains a number like (123) and all what you have to do is to add some digits on the left or the right of the (123) to make it divisible by M Hint about solving this problem, Or a solution for It?

constrains :- N<= 10^12 and M <= 2 * 10^5

Sample tests:-

(Test 1) 1 2 ===> 10 (Test 2) 2 11 ===> 22 (Test 3)234 823 ===> 12345

problem link: https://www.urionlinejudge.com.br/judge/en/problems/view/2788

And thanks In advance. :)

Read more »

 
 
 
 
  • Vote: I like it
  • +5
  • Vote: I do not like it

By hamobos499, history, 3 months ago, In English,

I has been 6 months since I start to solve problems from any online judge (Codeforces was the first one by the way) but since then, I barely notice a difference in my problem solving skills from now and 6 months ago even I had solve +100 problem and every time I register in a contest (div 2 or 3), my rate always decreases by -90 or more, and even If I managed to solve a problem It would be an A only.

So what should I do to improve my self even more? or begin a professional problem-solver requires lot of years practising? I'll be very grateful If you recommeded a few solutions based on your experience ^^

Thanks in advance.

Read more »

 
 
 
 
  • Vote: I like it
  • +3
  • Vote: I do not like it