#UVa:11044-Searching for Nessy

灆洢 2015-01-06 02:42:09

由於邊界可不計,即是指說除不盡則完全捨棄,故只要(n/3)*(m/3)即是答案。

C++(0.019)

/*******************************************************/
/* UVa 11044 Searching for Nessy                       */
/* Author: Maplewing [at] knightzone.studio            */
/* Version: 2015/01/06                                 */
/*******************************************************/
#include <iostream>
#include <cstdio>
using namespace std;

int main(){
  const int gridSize = 3;

  int t;
  while( scanf("%d", &t) != EOF ){
    for( int testcase = 1 ; testcase <= t ; ++testcase ){
      int n, m;
      scanf("%d%d", &n, &m);

      printf("%d\n", (n / gridSize) * (m / gridSize));
    }
  }
  return 0;
}

發表迴響

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料