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 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
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.net/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