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 1224. Spiral

Just don't get it! My prog got AC with "unsigned int n,m" and with "long" it failed!!!
Posted by ValBG 11 Feb 2003 03:58
#include <iostream.h>

int main()
  {
   unsigned int n,m;      //when this is long i get WA
   cin>>n>>m;
   if (n<=m) cout<<2*(n-1); else cout<<2*m-1;
   return 0;
  }
Re: Just don't get it! My prog got AC with "unsigned int n,m" and with "long" it failed!!!
Posted by Leonid Volkov 11 Feb 2003 11:53
But why do you think tha's strange? You write 2*(n-1) in your code,
thus, since n<2^31, 2*(n-1) could be close to 2^32, and you are to
use unsigned.