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 | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
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://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