In B I don't think so we have to do this much work we can just simply do the same calculations with x only no need to do it by making it base y I did this after the contest by realising that after x becomes 1 we can just simply do the given calculation. It caused me tle #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { long long x, y, k; cin >> x >> y >> k; while (k > 0){ long long need = y-(x%y); if (k < need) { x += k; k = 0; } else{ x += need; k -= need; while(x%y == 0){ x = x/y; } if(x==1){ x = 1 + k%(y-1); break; } } } cout
@AnupamSingh-of2ux
Ай бұрын
exactly same i had did but forgot about x==1 which caused the mistake
@learninginmyway4621
Ай бұрын
great💥
@amirakhaled9028
Ай бұрын
❤❤Great explanation
@theUnkown617
Ай бұрын
hey shayan, nice explanation I want to know how we will solve D if it is given we can take any k greater than 1
@amgadshrief7215
Ай бұрын
TOP
@anshumanacharya9812
Ай бұрын
Could you please explain why you use constant variables in almost all your codes??
@mrak5748
Ай бұрын
How many hours you guys give to CP daily?
@39_jatinjain4
Ай бұрын
Can anyone tell why que(C) wrong answer 475th numbers differ - expected: '1', found: '0' void solve() { ll n, l, r; cin >> n >> l >> r; v(n); stackst; for (int i = n - 1; i >= 0; i--) st.push(v[i]); ll cnt = 0; while (!st.empty()) { if (st.top() >= l && st.top() = l && st.top() = l && sum
@paarthjindal4100
Ай бұрын
arey tum yaha par bhi 🤣🤣
@39_jatinjain4
Ай бұрын
@@paarthjindal4100 hmm 2-3 main channel 😂🥲
@roonywalsh8183
Ай бұрын
i havent read your code , but for me when my code was greedy, i got caught up on the following scenario - consider the array to be 4 4 1 5 and l and r both are 10 , then the greedy approach fails since you wont be able to be sure if you would be taking the elements that are smaller than l
Пікірлер: 15