| 323 | } |
| 324 | |
| 325 | int cnroot(int n, int x) { |
| 326 | if (x < 2) |
| 327 | return x; |
| 328 | /* |
| 329 | * We look for u such that: (u-1)^n < x <= u^n |
| 330 | */ |
| 331 | long long int l = 1; |
| 332 | long long int u = x; |
| 333 | do { |
| 334 | long long int m = (l + u) >> 1; |
| 335 | if (powle(n,m,x)) l=m; else u=m; |
| 336 | } while (l+1 < u); |
| 337 | return static_cast<int>(u); |
| 338 | } |
| 339 | |
| 340 | /// %Test for nroot constraint |
| 341 | class NrootXY : public Test { |