Блог пользователя Ankush08

Автор Ankush08, история, 4 года назад, По-английски

I was attempting this problem : https://codeforces.me/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?

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор Ankush08, история, 4 года назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -13
  • Проголосовать: не нравится

Автор Ankush08, история, 4 года назад, По-английски

I was trying this problem: Boboniu and Bit Operations ( https://codeforces.me/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://codeforces.me/contest/1395/submission/109813483 (My approach). Please if someone could help, it would be very much appreciated.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -9
  • Проголосовать: не нравится

Автор Ankush08, история, 4 года назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -12
  • Проголосовать: не нравится