| Show all threads Hide all threads Show all messages Hide all messages |
| can DP solve this data? | cyc | 1031. Railway Tickets | 26 Aug 2013 02:18 | 5 |
3 100 10000 100 101 102 35 1 34 0 3 3 3 ... 3 99 100 i guess the answer is 201(1-35-34) can DP give this answer? i think only ShortestPath can give this answer. It's wrong answer. Right answer is 101. I agree with you. for example 1 2 100 100 100 1 4 2 3 2 3 99 when I used this input,my AC programm gave the answer 100 while the correct answer was 2 Distances are different(!) integer numbers given in ascending order. So this test isn't correct. Edited by author 10.05.2012 20:35 hey @bill125 if L2 < X ≤ L3 then cost is C3. // from table in problem statement if 2 < X ≤ 100 then cost is 1 . As X is 1 you can't use C3=1. |
| Help,plz..WA#8 | ZasorinE [USU] | 1931. Excellent Team | 25 Aug 2013 22:34 | 1 |
WA#8 #include<iostream>; using namespace std; int main() { int a[100002],i,n,record,maxrecord,irecord,imax,nmax; cin >> n; cin >>a[1]; imax=1; nmax=a[1]; record=1; irecord=1; maxrecord=1; for(i=2;i<=n;i++) { cin >> a[i]; if (a[i]>nmax) { ++record; if (maxrecord<record) { maxrecord=record; irecord=imax; } } else { imax=i; nmax=a[i]; record=1; } } cout << irecord; system ("PAUSE"); return 0; } |
| Help me, please! | Jane | 1047. Simple Calculations | 25 Aug 2013 21:24 | 7 |
Дайте, пожалуйста, подсказку... Oh, no! It is not interesting to solve this problem with binary search. Here is a formula. You have to find it yourself :) But it's not so difficult to find it. Just replace a1 with a0 and a2, then a2 with a1 and a3,... After four or five such replaces you will see dependence. Edited by author 04.07.2012 11:30 Deriving formula for calculation of a1 makes it simple. |
| I cannot detect error (WA1) Please help me :) | Mickkie | 1748. The Most Complex Number | 25 Aug 2013 20:09 | 1 |
#include<stdio.h> #include<math.h> #include<map> using namespace std; map<unsigned long long,int> M;
int Prime[30]={0,2,3,5,7},Pct=5; void genprime(int); int expP[30]={70},solVal[500],ctsol; unsigned long long solKey[500]; void gensol(unsigned long long,int); void arrange(); main() { genprime(30); gensol(1,1); arrange(); //for (int i=1;i<=ctsol;i++) printf("%lld %d\n",solKey[i],solVal[i]); int Test,id; unsigned long long n; scanf("%d",&Test); for (int t=1;t<=Test;t++) { scanf("%llu",&n); id=ctsol; while (solKey[id]>n) id--; printf("%llu %d\n",solKey[id],solVal[id]); } } void genprime(int K) { int i,j; for (i=11;Pct<K;i+=2) { for (j=1;Prime[j]*Prime[j]<=i;j++) if (i%Prime[j]==0) break; if (Prime[j]*Prime[j]>i) Prime[Pct++]=i; } //for (int i=1;i<Pct;i++) printf("%d\t",Prime[i]); } void gensol(unsigned long long x,int pID) { int i,pro=1; for (i=1;i<30;i++) pro*=expP[i]+1; M[x]=pro;
if (log10(x)+log10(Prime[pID])<=18.3 && expP[pID]<expP[pID-1]) { expP[pID]++; gensol(x*Prime[pID],pID); expP[pID]--; } if (log10(x)+log10(Prime[pID+1])<=18.3 && expP[pID]!=0) { expP[pID+1]++; gensol(x*Prime[pID+1],pID+1); expP[pID+1]--; } } void arrange() { map<unsigned long long,int>::iterator it; for (it=M.begin();it!=M.end();it++) { if (it->second > solVal[ctsol]) { ctsol++; solKey[ctsol]=it->first; solVal[ctsol]=it->second; } } } |
| To admins: Reduce Time limit | Georgi_georgiev | 1353. Milliard Vasya's Function | 25 Aug 2013 17:01 | 4 |
My source is consisted of 8 cycles from zero to nine and one counting and works for 0.356 or something like that. Yes, bruteforce algo with 8 cycles AC. :) But with 9 cycles got TL. Edited by author 14.07.2009 00:30 Why 8, not 9? Because 9th you can calculate. P.S. Yes, I'm necroposter XD Edited by author 25.08.2013 17:02 Edited by author 25.08.2013 17:02 |
| What the output means? | phizaz | 1029. Ministry | 25 Aug 2013 14:29 | 2 |
I don't understand what the output means? thanks for help! OUTPUT: 3 3 2 1 1 MOVE 1: 1st floor [3]rd room MOVE 2: 2nd floor [3]rd room MOVE 3: 2nd floor [2]nd room MOVE 4: 2nd floor [1]st room MOVE 5: 3rd floor [1]st room More Detailed: Let out[] be the output array. If out[i] == out[i+1] then it means that you go one floor up, as there is no point in revisiting the same official. Otherwise you go to one of the neighboring rooms. If out[i] + 1 == out[i+1] then you go to the right neighboring room. Else if out[i] - 1 == out[i+1] then you go to the left neighboring room. Hope it helped you. And hope that my C-style like syntax didn't make it hard to understand :) Edited by author 25.08.2013 14:31 |
| If you have WA #6 or WA #2 | Plamen_N | 1910. Titan Ruins: Hidden Entrance | 25 Aug 2013 11:34 | 2 |
For WA #6: It is not necessarily the three consecutive numbers to be equal. So if you have the test: 3 1 2 3 the answer should be 6 2. For WA #2: The consecutive numbers, which you sum, have to be exactly three. |
| Help plz :) | Dzale | 1459. Archer's Travel | 25 Aug 2013 03:47 | 4 |
can any1 tell me what is solution for 4x4,4x5 and 4x6, also some hints would be nice :D Thanks 4х4 12 4х5 28 4х6 74 4х12 19540 Edited by author 18.04.2012 22:32 What answer for 5 x 6 Edited by author 12.10.2012 19:31 For 5 x 6 answer is 308. For 5 x 7 answer is 0. For 5 x 8 answer is 3392. For 5 x 1000000000 answer is 937261824. Edited by author 25.08.2013 03:48 |
| How to solve this problem? | HybridTheory | 1332. Genie Bomber | 24 Aug 2013 17:48 | 20 |
I've no idea.Could anybody help me? I have the same question. I think if distances between all pairs of cities of chosen subset are less or equal to R then this subset can be destroyed. But i don't know how to find this subset quickly. 1. R = R - r; Then You will solve problem with N points and a circle of radius R 2. Build 2 circles thru all pairs of points (it is n*(n-1) circles) and calculate amount of points in this circles. Maximum of them is the answer. Sorry for my bad english :-) Thank you first. And I have a little question,why we can do the first step? Edited by author 28.10.2004 20:50 I mean,you say first we can let R=R-r to make the cities become points.I don't know why we can do this. Because city can be destroyed by djin only if d+r<=R => d<=R-r (d - distance between center of city and djin). Edited by author 29.10.2004 16:27 Are you sure? Maybe I have not understood your solution properly, but what your solution does in case on 2 distant sets of cities. Each set can be destroyed by 1 bottle. For example 4 cities. 0 0 1 1 100 100 101 101 And R = 3, r = 0; Your solution would be 4, but it's, obviously, 2. This means that I have not understood what you have written... Then how do you process the case which I have presented? Maybe it would be better to continue this conversation via e-mail? Ok. my e-mail is marilyn_manson@bk.ru I think Vic right sorry my bad English Build 2 circles thru all pairs of points (it is n*(n-1) circles) One for center and one determines the length of the radius? If so, then I am confused with your solution... Edited by author 04.08.2006 23:52Of course not! Both points are lying on the circle Barinov jjot. Strange but it works since first submit! Thanks a lot!!! Why 2 circles? And what is the center of those circles? 2 points can make 2 circles with the exact R. (from two different directions!) I am also confused just know. :) No. For example there are 2 circles, which have points (-3; 0) and (3; 0) and R = 5: with center in (0; 4) and (0; -4) |
| WA20, tests or a hint needed | PrankMaN | 1332. Genie Bomber | 24 Aug 2013 17:23 | 1 |
|
| Test #10. | the_swede | 1031. Railway Tickets | 24 Aug 2013 01:27 | 2 |
According to the problem statment 1 ≤ L1 < L2 < L3 ≤ 10 ** 9, 1 ≤ C1 < C2 < C3 ≤ 10 ** 9 but test #10 fails with integers (32-bit) for Li and Ci. I fixed WA #10 by lowering my infinity constant to 1100000000. |
| Почему не работает?? | Jacob | 1820. Ural Steaks | 23 Aug 2013 20:05 | 2 |
var n,k,x: integer; prov,res:real; begin read(n,k); x:=n*2; res:=x/k; res:=trunc(res); writeln(res); end. нужна функция не trunc(), a ceil(). |
| I got AC with time 0.875s | degree | 1091. Tmutarakan Exams | 23 Aug 2013 17:16 | 1 |
just dfs and pre calculate gcd. |
| Some tests | Georgiy Platonov | 1929. Teddybears are not for Everyone | 23 Aug 2013 13:36 | 2 |
As far as I can see, there are not so much test cases published in the problem's forum at this moment. So I think I should fill the gap. Here are tests and my AC program's answers. I hope these will help. 6 3 1 2 3 answer: 9 9 3 1 2 3 answer: 15 9 3 2 3 4 answer: 15 9 1 1 answer: 0 15 6 1 2 3 4 5 6 answer: 81 15 6 2 3 4 5 6 7 answer: 63 15 7 1 2 3 4 5 6 7 answer: 91 999 500 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 5 7 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 answer: 497503 900 400 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 answer: 279400 |
| Pascal Compilation error. Why? | Michael | 1585. Penguins | 23 Aug 2013 10:57 | 3 |
It works on my laptop. I have Pascal ABC. var A:array[1..1000]of string; B:array[1..3]of integer; c,d:integer; begin readln(c); for d:=1 to c do begin readln(A[d]); if A[d]='Emperor Penguin'then B[1]+=1; if A[d]='Little Penguin'then B[2]+=1; if A[d]='Macaroni Penguin'then B[3]+=1; end; d:=max(max(B[1],B[2]),B[3]); if d=B[1]then write('Emperor Penguin'); if d=B[2]then write('Little Penguin'); if d=B[3]then write('Macaroni Penguin'); end. function max(x,y:integer):integer; begin if x>=y then max:=x else max:=y; end; Thanks. I didn't know that FreePascal doesn't know this function max(). Edited by author 23.08.2013 10:58 |
| No subject | daria | 1971. Graphics Settings | 23 Aug 2013 01:06 | 1 |
Edited by author 23.08.2013 19:43 Edited by author 23.08.2013 19:43 |
| When I use g++4.7.2 get MLE, but visual c++ I get AC (same code) | Pegasus | 1220. Stacks | 22 Aug 2013 15:31 | 1 |
|
| What's mean this problem? | stat958 | 1753. Bookshelf | 22 Aug 2013 06:57 | 1 |
What's mean this problem? |
| Proof of solution | Ilian | 1082. Gaby Ivanushka | 21 Aug 2013 22:07 | 1 |
Everybody who knows quick sort will recognize that the tsar's program is quick sort of N numbers. Let we have a sorted array with n numbers. Let l-r+1=k. Then function P() will increase the value of c by k+1 because it will visit all x elements to distribute them into part smaller than or equal to x and part greater or equal to x. That increases c by k. But the i and j iterators must be equal so there is also one additional increase of c. Because we have a sorted array function P() will partition him into part consisting of 1 element and part consisting of l-r elements. The part consisting of 1 element will be ignored and there won't be any increase of c. In the part with l-r elements it will do the same - partitioned it into 1 and l-r-1. So let begin with l-r+1=N. Then the function Q() will go to l-r+1=N-1 and so on to l-r+1=2. For those calls of function Q() c will be increased with: N+1 + N + N-1 + ... + 5 + 4 + 3 = (N+1)*(N+1+1)/2 - 1 - 2 = N*N + 3*N + 2/2 - 3 = =N*N + 3*N + 2 - 3*2/2 = N*N + 3*N - 4 / 2. So if we give a sorted array to the tsar's program it will print what we want. What is more, we prove that for sorted array quick sort is very bad algorithm with such bad complexity. Note: If the median element was chosen in a different way the solution won't be so easy. But it can be done if we try all permutations of array with elements from [1;n] and check for c. Edited by author 21.08.2013 22:19 |
| WA #5 | R. Dubinin | 1869. New Year Cruise | 20 Aug 2013 17:50 | 1 |
WA #5 R. Dubinin 20 Aug 2013 17:50 please give me some tests |