Ankush08's blog

By Ankush08, history, 4 years ago, In English

I was attempting this problem : https://mirror.codeforces.com/contest/628/problem/D and came up with a solution which basically look like this :

int d, m;

ll int magicNumberDP(string n, int idx,ll int curNum, bool tight) {
	if (idx >= n.length()) {
		return !curNum ;
	}

	int uprBnd = (tight) ? n[idx] - '0' : 9 ;

	ll int ans = 0 ;

	for (int dig = 0 ; dig <= uprBnd ; dig++) {
		if ((idx + 1) % 2 == 0 and d != dig) {
			continue ;
		}

		if ((idx + 1) % 2 == 1 and d == dig) {
			continue ;
		}

		ans = ans + magicNumberDP(n, idx + 1, (curNum * 10 + dig) % m, tight & (dig == uprBnd)) ;
	}

	return ans;
}

void magicNumber() {
	cin >> m >> d ;
	ll int r, l;
	cin >> l >> r ;

	l--;

	string R = to_string(r);
	string L = to_string(l);

	int ansR = magicNumberDP(R, 0, 0ll, 1);

	int ansL = magicNumberDP(L, 0, 0ll, 1);

	cout << ansL << " " << ansR << endl ;
	cout << ansR - ansL << endl;
}

But this is giving wrong answer can someone tell me why I am wrong and how can I correct it?

Full text and comments »

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

By Ankush08, history, 4 years ago, In English

Hi CF community,

I am really struggling with Division 2 C & D, I am sometimes able to think of logic but not able to implement, or think of an approach which gives TLE. I have tried practicing in several different ways like : 1. Choosing a difficulty range like 1500-1600 and solving problems in that difficulty range . 2. Trying Div 2 C and D problems of previous contest

Even after all this I still am not improving, IK you might have seen a lot of people saying this and the answer is always "Just keep practicing" But if anyone could give advice it would be highly appreciated.

I am asking this because all the blogs regarding this topic I found were from 2-3 or even 4 years AGO.

Full text and comments »

  • Vote: I like it
  • -13
  • Vote: I do not like it

By Ankush08, history, 4 years ago, In English

I was trying this problem: Boboniu and Bit Operations ( https://mirror.codeforces.com/problemset/problem/1395/C ) and in the solution, it suggested finding the answer by brute force that tries all 2^9 numbers. My doubt is, how come just choosing the minimum and of ai and bj not optimal? My solution: https://mirror.codeforces.com/contest/1395/submission/109813483 (My approach). Please if someone could help, it would be very much appreciated.

Full text and comments »

  • Vote: I like it
  • -9
  • Vote: I do not like it

By Ankush08, history, 4 years ago, In English

Hi there CF community , I am currently able to do Div2 A & B and want to also be able to do C problem for that i saw that everyone was recommending A20J Ladders , while i appreciate the effort someone took to make that i realized that those are like 5-6 years OLD ! ! Which makes me wonder are they still relevant and moreover Helpful as per today's and future standards ? ?

I really urge senior cp-programmers to please advice me on how i should practice as of 2020 ? should i keep following A20J or can you give me some other curated list or any other method ?

Please help.

Full text and comments »

  • Vote: I like it
  • -12
  • Vote: I do not like it