ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1079. Maximum

This is O(1) logic - getting WA
Posted by Sridhar 23 Jul 2004 07:47
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
Posted by Died 23 Jul 2004 12:41
You can't get AC with this code because it's WRONG!
2 Died: Please, be polite! (-)
Posted by Dmitry 'Diman_YES' Kovalioff 24 Jul 2004 19:55
Re: This is O(1) logic - getting WA
Posted by Anton Chupin 19 Feb 2005 17:14
Because maxima in the sequence are not log(2,n)!