guys i need help on this problem: https://codeforces.me/contest/2072/problem/A
can someone tell me how to start i am very confused, do i need to know DFS for this?
# | User | Rating |
---|---|---|
1 | tourist | 3857 |
2 | jiangly | 3747 |
3 | orzdevinwang | 3706 |
4 | jqdai0815 | 3682 |
5 | ksun48 | 3591 |
6 | gamegame | 3477 |
7 | Benq | 3468 |
8 | Radewoosh | 3463 |
9 | ecnerwala | 3451 |
10 | heuristica | 3431 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | -is-this-fft- | 162 |
3 | Qingyu | 159 |
3 | Dominater069 | 159 |
5 | atcoder_official | 157 |
6 | Um_nik | 153 |
6 | adamant | 153 |
8 | djm03178 | 151 |
8 | luogu_official | 151 |
10 | awoo | 147 |
guys i need help on this problem: https://codeforces.me/contest/2072/problem/A
can someone tell me how to start i am very confused, do i need to know DFS for this?
Name |
---|
No, you don't need DFS for this problem.
For this kind of question, first try searching for a solution on the internet. If you still can't find a good one, then ask here.
sorry man usually i solve question a but this time the question makers gave bad one
this is pure adhoc, you gotta make sure that abs(k) is smaller than or equal to n*p, if not then it is impossible, else just cout k/p (you will need to add 1 if k is not divisible by p).
thanks but what is adhoc? can you write adhoc alogrithm in c++ here for me because i still don't get it.
in short, adhoc problems have no standard way to solve, it is just like trying to capture a pattern for the problem, there is no way to standardize adhoc problems, you just get better with time.
for this problem a solution will be smthin like this:
k = abs(k);
if (k > n*p) cout << -1 << '\n';
else cout << (k/p) + (1*(k%p!=0)) << '\n';
Min=abs(k)//p if abs(k)%p==0 else Min=abs(k)//p+1
Print -1 if n<Min else print Min
You can do this .It's way simpler
Min=(abs(k)+p-1)//p
skill issue