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)).
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3741 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3489 |
7 | Radewoosh | 3483 |
8 | Kevin114514 | 3442 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
2 | atcoder_official | 162 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | nor | 150 |
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)).
Название |
---|
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://mirror.codeforces.com/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