Advertisement
erfanul007

LOJ 1010

Dec 2nd, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 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. if(x%4 == 1)
  18. ans = x+1;
  19. else if(x%4==2)
  20. ans = x+2;
  21. else if(x%4==3)
  22. ans = x+1;
  23. else if(x%4==0)
  24. ans = x;
  25. }
  26. else if(mn%2==0)
  27. ans = mn/2;
  28. else
  29. ans = (mn/2)+1;
  30. printf("Case %d: %d\n", i, ans);
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement