http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1985
import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int cases = scan.nextInt(); while(cases--!=0){ int r = scan.nextInt(); int c = scan.nextInt(); r-=2; c-=2; int $r,$c; if(r%3!=0) $r=r/3+1; else $r=r/3; if(c%3!=0) $c=c/3+1; else $c=c/3; System.out.println($r*$c); } } }
沒有留言:
張貼留言