Advertisement
erfanul007

Light OJ 1010

Dec 29th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int t,i,n,m,mn,x,ans;
  5. scanf("%d",&t);
  6. for(i=1;i<=t;i++){
  7. scanf("%d %d",&n,&m);
  8. mn = n*m;
  9. if(n==1 || m==1)
  10. ans = mn;
  11. else if(n==2 || m==2)
  12. {
  13. if(n==2)
  14. x = m;
  15. else
  16. x = n;
  17. ans = x;
  18. if(x%4 == 1 || x%4==3)
  19. ans++;
  20. else if(x%4==2)
  21. ans += 2;
  22. }
  23. else if(mn%2==0)
  24. ans = mn/2;
  25. else
  26. ans = (mn/2)+1;
  27. printf("Case %d: %d\n", i, ans);
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement