Elkhateb's blog

By Elkhateb, history, 2 years ago, In English

[problem:https://codeforces.net/group/j67LErd7ji/contest/389254/problem/F][contest:https://codeforces.net/group/j67LErd7ji/contest/389254] my submission linK:https://codeforces.net/group/j67LErd7ji/contest/389254/problem/F I tried hard with this problem this is my solution but it gets TLE any helpful tips? ~~~~~

int main() { int t; cin>>t; while(t--){ ll n,q; cin>>n>>q; vectorarr(100000,0),arr2(100000,0); arr2[0] = 0; for(ll i=1;i<=n;i++) { ll lol; cin >> lol; if((lol)%2==0){

if(log2l(lol)==ll(log2(1.0L*lol)))
                arr[i] = log2(lol);
            else{
                arr[i] =  ceil(log2((1.0L*lol)));
            }
        }else{
            lol--;
            if(log2l(lol)==ll(log2(1.0L*lol)))
                arr[i] = log2(lol)+1;
            else{
                arr[i] =  ceil(log2(1.0L*lol))+1;
            }
        }
        arr2[i]+=arr2[i-1]+arr[i];

// cout<<arr[i]<<" "; } // cout<<el; // for(int i=1;i<=n;i++){ // arr2[i] = arr2[i-1] + arr[i]; // } while(q--){ int l,r; cin>>l>>r; cout<<arr2[r] — arr2[l-1]<<'\n'; } }

return 0;//Q.E.D ^_^

} ~~~~~

Full text and comments »

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

By Elkhateb, history, 2 years ago, In English

ax+by=c where a,b,c are given integer numbers. I know that for linear equations, there is exist a solution if and only if c is a multiple of d =gcd(a,b). This is called Bezout's lemma. In the following problem, I write a solution to check the answer, but it gives me a wrong answer in test 23 which is 14x+19y = 143. any help why did this happen? link to the problem

Full text and comments »

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

By Elkhateb, history, 2 years ago, In English

Are there any tips to overcome this problem, I face a lot of problems that I really don't understand what he really needs! sometimes my thinking about the problem is wrong and I spent a lot of time trying to implement my wrong thinking about the problem and finally it's wrong! Any useful tips will help. thanks for your time.

Full text and comments »

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

By Elkhateb, history, 2 years ago, In English

I know basic data structures like an array, vector,pair..etc. I also practice some recursion functions, but not good at analyzing the complexity of my functions!

Full text and comments »

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

By Elkhateb, history, 2 years ago, In English

I had the following sequence

5 1 11 2 8 And I need to make 5 greater than any element in the given sequence with minimum operations..there is a solution for this using while and sorting...etc. I wonder if there is some way to know the solution with the enclosed formula?? I think that I can get 11 — 5 = 6 and then divide 6 by 2 --> 3 and then 5 will be 8 ..but it's not the greatest element then I can just add 1, the answer will be 4 -->(9-5). **** another test case will be 1 8 8 8 i can make the sequence 7 6 6 6 ..the answer is 7-1 = 6 operations . I can analyze this solution into the following : 1 + (3 * 2 ) > 6. where 3 is the occurrence of the biggest element in the sequence.... and 1 is the first element?? Is my thinking wrong?? another test case 16--> number of elements 7 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 I solve it to 990 ..but the optimal is 932!!!!

link to the problem I checked the tutorial ..but couldn't find the problem explanation in it!

Full text and comments »

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

By Elkhateb, history, 2 years ago, In English

I want to learn how to be good at proofs... I see a lot of problems.

The solution needs proofs i really don't know to be able to proof..i watched a lot of videos,and I can understand them.the books that i read are very hard to them.. So any help.. Any practical way or tips or channels or anything!!

Full text and comments »

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