Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
Good simulation problem | silverfox | 1131. Копирование | 28 апр 2022 22:29 | 1 |
Hint: we start from kk = 1, then kk += kk (2), kk += kk (4) but we cannot advance when kk > k. get to the maximum kk with this and the remaining n - kk can be easily calculated with (n - kk) / k + (((n - kk) % k) > 0) |
WA10, help me please) | Roman Hrynevych | 1131. Копирование | 1 сен 2021 15:18 | 2 |
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> int main() { int n, k; scanf("%d %d", &n, &k); if (n < 1 || n > pow(10, 9) || k < 1 || k > pow(10, 9)) { return 0; } unsigned long long result = 0; unsigned long long buffer = 1; n--; for (int i = 0; n >= 0; i++) { n -= buffer; result++; buffer *= 2; if (n <= 0) { printf("%llu\n", result); return 0; } if (buffer >= k) { buffer = k; double count = (double)n / buffer; if (count != (long long)count) { count++; } result += count; printf("%llu\n", result); return 0; } } return 0; } Edited by author 21.01.2020 01:57 |
No subject | shawn | 1131. Копирование | 22 июн 2021 13:37 | 1 |
Edited by author 23.06.2021 07:43 Edited by author 23.06.2021 07:43 Edited by author 23.06.2021 07:43 |
WA2 Hint | Sukarna Paul | 1131. Копирование | 13 апр 2021 17:51 | 1 |
The program is already installed in one computer. Now, we need to install it in (N-1) computers. |
if WA3 | Programmer956 | 1131. Копирование | 13 янв 2021 09:49 | 2 |
if WA3 Programmer956 3 апр 2020 21:49 if k > n my program worked with n < 0 you should to consider the case after cycle: if n < 0 then n = 0 Edited by author 03.04.2020 21:51 |
time exceeded。。can you help me make it faster? | xinxin | 1131. Копирование | 15 май 2020 04:21 | 3 |
#include<stdio.h> #include<math.h> int main() { int n,k,i=1,s=1,t=0,temp=0; scanf("%d %d",&n,&k);
while(i<k) { s=s+i; i=2*i; t++;
if(s>=n) break; } while(s<n) { s=s+k; t++; } printf("%d",t); return 0; } while(s<n) { s=s+k; t++; } Isn't here (n-s)/k iterations? #pragma optimize( "g", on ) |
time limit on python 3 HELP PLEASE I GIVE MONEY | ivan228 | 1131. Копирование | 13 фев 2020 06:12 | 2 |
import sys n,k=map(int,input().split()) ans=0 nn=1 on=1 if n==1: print(0) sys.exit() for i in range(100000000000000000000): if on<=k: nn+=on on+=on ans+=1 elif k<n: nn+=k on+=k ans+=1 if nn>=n: print(ans) sys.exit() i can not understand why optimization my cod if i got ac with you help i give you 1000 rubles Edited by author 17.10.2018 22:35 The reason why you got time limit is that you don't use optimal algorithm. Your algorithm can be even correct, but to pass you need downgrade your algorithm. Maybe you could find some formula that would describe the whole process. Python is not the case here. You would get the same time limit issue with C. I launched your script with N = 10000000 and K = 2 and it took 1.833s on my machine to get the correct answer when the time limit is 0.25s. Of course it will grow up nonlinearly with bigger N. So it would take ages with N = 10^9 (the edge value). $ time echo "10000000 2" | python 1131_bruteforce.py real 0m1.833s user 0m1.824s sys 0m0.007s if i got ac with you help i give you 1000 rubles Edited by author 17.10.2018 22:35 P.S. I don't need your money if you finally solve it :) Edited by author 13.02.2020 06:12 Edited by author 13.02.2020 06:12 |
Test 10 hint | Yan_Olerinskiy | 1131. Копирование | 23 янв 2020 02:30 | 1 |
|
WA5 What is wrong? help pls. | Dmitry_Terenichev | 1131. Копирование | 16 янв 2020 21:13 | 2 |
var n,k,ch,im:int64; begin read(n,k); n:=n-1; ch:=0; im:=1; while n>0 do begin if im<=k then begin n:=n-im; im:=im*2; ch:=ch+1; end; if im>k then begin n:=n-k; im:=im+k; ch:=ch+1; end; end; writeln(ch); end. well, i've also had WA 5, i tried to enter 4 2 and got 3 instead of 2. i found the mistake but then i got WA 14. i tried 6 4 and got 4 instead of 3 and understood that i had corrected the code wrong and only then i got AC. Edited by author 16.01.2020 21:20 Edited by author 16.01.2020 21:20 |
WA 2 | DejaVu | 1131. Копирование | 5 окт 2019 23:01 | 1 |
WA 2 DejaVu 5 окт 2019 23:01 #include <iostream> using namespace std; int main() { long int n, k; cin >> n >> k; long int a = 1; long int h = 0; if(n == 1){ cout << 0; } else if(n == 2){ cout << 1; } else{ while(n != 0){ if(a > k && a < n){ a = k; n -= a; h++; } else if(a > n){ n = 0; h++; } else{ n -= a; a *= 2; if(a > k){ a = k; } h++; } } cout << h; } } |
for those ,who don't know what to do with WA 7,8; | Ivan | 1131. Копирование | 4 июн 2019 22:49 | 1 |
I tried to pick up to my occasion all data types ,but there was some problem ;Then i tried using data type "auto" and it's worked! |
WA 2 py 3.6 | DonCezario | 1131. Копирование | 16 апр 2019 01:33 | 1 |
n, k =map(int, input().split(' ')) z=0 time=0 num = 1 progress = 2 if k==1 and n==1: print(n) elif k ==1: print(n-1) elif k>=n: time+=1 while num<n: num+=progress progress*=2 time+=1 print(time) else: time+=1 while z==0: if progress<=k and num<n: num+=progress progress*=2 time+=1 else: z+=1 progress=k if num<n: while num<n: if num<n: time+=1 num+=progress print(time) Edited by author 16.04.2019 01:34 |
What is TLE at test 8?? | Iqramul Islam | 1131. Копирование | 11 мар 2019 01:48 | 1 |
|
what is test 6????? Please Heeeeelp!!! | Yusufjon | 1131. Копирование | 30 июл 2018 19:16 | 1 |
I can't find mistake, help!! #include <iostream> #include <cmath> using namespace std; int main() { __int64 n,k; int s = 0; cin>>n>>k; int step; step = log(k)/log(2); if(n-pow(2,step+1)>=0) { n -= pow(2,step+1); s = (step+1)+ceil(n*1./k); } else { s = ceil(log(n)/log(2)); } cout<<s; } |
I have one formula but WA8. Give me some tests pls | Feriter | 1131. Копирование | 29 июл 2018 12:58 | 1 |
Formula: ceil(log2(min(n, k))) + ceil((double)(n - (1 << (int)(ceil(log2(min(n, k))))))/ k) Edited by author 29.07.2018 13:01 Edited by author 09.09.2018 17:50 |
Wrong answer on Test Case 4: | FN2187 | 1131. Копирование | 1 май 2018 11:13 | 1 |
Here is my code: int main() { int N, K; cin >> N >> K; int connect = 1; int temp = N; int largepow = 0; // calculate the largest power of 2 less than K while(temp > 0) { if(pow(2, largepow) < K && pow(2, largepow + 1) < K) largepow++; temp /= 2; } N--; int count = 0; // count the hours while(N > 0) { N -= connect; count++; if(connect < pow(2, largepow)) connect *= 2; else if(connect >= pow(2, largepow) && connect < K) connect++; } cout << count; return 0; } Got WA4, then I tried something else: int main () { long long n, k, exp; cin >> n >> k; for (exp = 0; (1 << exp) < n && (1 << exp) < k; exp++) if ((1 << exp) < n) exp += ((n - (1 << exp) - 1) / k) + 1; cout << exp; return 0; } Test case 4 again. What is wrong? |
WA6 | hatred | 1131. Копирование | 5 апр 2018 20:27 | 5 |
WA6 hatred 13 авг 2011 01:33 where is my mistake? #include <cstdio> #include <cmath> inline int lb(int n) { return ceil(log(double(n))/log(2.0)); } int main() { int n,k; scanf("%d%d",&n,&k); if (n<=k) printf("%d",lb(n)); else { int ans=lb(k); n-=1l << ans; ans+=n/k; if (n%k) ++ans; printf("%d",ans); } } I got WA6 too...can you please tell me the case? Re: WA6 Siroj Matchanov [TUIT] 9 фев 2018 04:11 Whoever gets Wrong Answer at 6th test, try to change your way of finding the power of two. My solution got WA#6 when I calculated power of two this way: power = ceil(log(x)/log(2)); Better calculate it by multiplying it. Re: WA6 Sergey Nikolaev 5 апр 2018 20:27 Could you explain, why it is better ? |
Test 6 | Shorekh | 1131. Копирование | 9 фев 2018 04:11 | 2 |
Test 6 Shorekh 20 окт 2016 22:48 Re: Test 6 Siroj Matchanov [TUIT] 9 фев 2018 04:11 Whoever gets Wrong Answer at 6th test, try to change your way of finding the power of two. My solution got WA#6 when I calculated power of two this way: power = ceil(log(x)/log(2)); Better calculate it by multiplying it. |
Wrong tests? n = 1 | marina311 | 1131. Копирование | 10 янв 2018 07:12 | 1 |
If n = 1 answer is 0, but accepted solution with answer 1. Why??? |
WA4!!HELP | elsukov43 | 1131. Копирование | 20 ноя 2017 00:34 | 6 |
Wrong answer 4. HELP!!!! Edited by author 03.06.2016 17:42 Edited by author 03.06.2016 17:42 What did you try? What's your solution/idea so far? #include "iostream" using namespace std; int main() { int n, k, hours = 0, game = 1, free, i = 0, j = 0; cin >> n >> k; free = k; if (n == 1) hours = 0; else { while ((free > i) && (game < free) && (game <= n)) { i++; n -= i; hours++; game += i; } while (j < n-1) { hours++; j += k; } } cout << hours << endl; return 0; } Edited by author 03.06.2016 17:44 Wrong answer 4! Edited by author 03.06.2016 17:30 Edited by author 03.06.2016 17:41 |