This is my solution: Solution(Not visible) Check my code below
For question : Question
It is giving TLE on Test 3.
My code
My solution is in O(t.log(p)).
# | User | Rating |
---|---|---|
1 | jiangly | 3976 |
2 | tourist | 3815 |
3 | jqdai0815 | 3682 |
4 | ksun48 | 3614 |
5 | orzdevinwang | 3526 |
6 | ecnerwala | 3514 |
7 | Benq | 3482 |
8 | hos.lyric | 3382 |
9 | gamegame | 3374 |
10 | heuristica | 3357 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | -is-this-fft- | 165 |
3 | Um_nik | 161 |
3 | atcoder_official | 161 |
5 | djm03178 | 157 |
6 | Dominater069 | 156 |
7 | adamant | 154 |
8 | luogu_official | 152 |
9 | awoo | 151 |
10 | TheScrasse | 147 |
This is my solution: Solution(Not visible) Check my code below
For question : Question
It is giving TLE on Test 3.
void solve(){
int k,i, j, q, x, y;
int h, p;
cin >> h >> p;
auto MS = [&] (int n){
int i = 0;
while(n){
i++;
n >>= 1;
}
i--;
return i;
};
int ms = MS(p)+1;
if(h <= ms){
print(h);
} else{
int ans = ms+((1<< h)-1 - ((1<<ms)-1)+p-1)/p;
print(ans);
}
}
My solution is in O(t.log(p)).
Name |
---|
you solution can't open to other people so can you write your code in spoiler to check it?
Added my code. Thanks in advance
add this line (ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);) to your code and see the result it will fast your input
cout.tie(0) does nothing
i just add the previous line and it give wrong answer instead of TLE
because of ios::sync_with_stdio(false) and cin.tie(0) they actually make ur program faster but cout.tie(0) is useless
upd: thx to -is-this-fft- https://codeforces.me/blog/entry/90775?#comment-791764
What have you written in "int ans="?
That's not my code. That's why you getting WA.
What is mdash?
I have already done that