|
|
вернуться в форумThis is O(1) logic - getting WA See this program .. the logic is AFAIK correct .. atleast for the first 20 or so numbers. --- ( '.' is used to simulate tabs ;) int main() { ....int n; ....while(1){ ........int cnt=0; ........scanf("%d", &n); ........if (!n) break; ........if (n>1) ............n--; ........while(n) cnt++, n>>=1; ........printf("%d\n", cnt); ....} ....return 0; } --- Can anyone explain what's wrong with this logic? Re: This is O(1) logic - getting WA Послано Died 23 июл 2004 12:41 You can't get AC with this code because it's WRONG! 2 Died: Please, be polite! (-) Re: This is O(1) logic - getting WA Because maxima in the sequence are not log(2,n)! |
|
|