思路:

根据案例的规律其实已经猜的差不多了,answer=n*m/2;

有一条边是1的情况,也很好判断,answer=n*m;

就是有一条边是2的时候比较隐秘:是连续2*2一块可以填,然后2*2不填,没想出总结的公式,就直接模拟了。

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
int main()
{
int cas=1,T;
int n,m;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&m);
int ans=(n*m+1)/2;
if(n==1||m==1)
ans=n*m;
else if(n==2||m==2)
{
ans=0;
n=n*m;
while(n>8)
{
ans+=4;
n-=8;
}
if(n>=4)
ans+=4;
else
ans+=n;
}
printf("Case %d: %d\n",cas++,ans);
}
return 0;
}

lightoj1010【规律】的更多相关文章

  1. LightOJ1010---Knights in Chessboard (规律题)

    Given an m x n chessboard where you want to place chess knights. You have to find the number of maxi ...

  2. hdu1452 Happy 2004(规律+因子和+积性函数)

    Happy 2004 题意:s为2004^x的因子和,求s%29.     (题于文末) 知识点: 素因子分解:n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en 因子 ...

  3. Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)

    传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...

  4. ACM/ICPC 之 DP解有规律的最短路问题(POJ3377)

    //POJ3377 //DP解法-解有规律的最短路问题 //Time:1157Ms Memory:12440K #include<iostream> #include<cstring ...

  5. HDU 5795 A Simple Nim 打表求SG函数的规律

    A Simple Nim Problem Description   Two players take turns picking candies from n heaps,the player wh ...

  6. 在sqlserver中做fibonacci(斐波那契)规律运算

    --利用sqlserver来运算斐波那契规律 --利用事物与存储过程 declare @number intdeclare @A intdeclare @B intdeclare @C int set ...

  7. 谈谈黑客攻防技术的成长规律(aullik5)

    黑莓末路 昨晚听FM里谈到了RIM这家公司,有分析师认为它需要很悲催的裁员90%,才能保证活下去.这是一个意料之中,但又有点兔死狐悲的消息.可能在不久的将来,RIM这家公司就会走到尽头,或被收购,或申 ...

  8. Math.abs(~2018),掌握规律即可!

    Math.abs(~2018) 某前端群的入门问题长姿势了,一个简单的入门问题却引发了我的思考,深深的体会到自己在学习前端技术的同时忽略遗忘了一些计算机的基础知识. 对于 JS Math对象没什么可说 ...

  9. COM中需要调用AddRef和Release的10条规律

    COM中需要调用AddRef和Release的10条规律  

随机推荐

  1. Django项目高频使用文件

    数据库配置: MySQL数据库 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'HOST': 'localhost' ...

  2. 【JAVA学习】struts2的action中使用session的方法

    尊重版权:http://hi.baidu.com/dillisbest/item/0bdc35c0b477b853ad00efac 在Struts2里,假设须要在Action中使用session.能够 ...

  3. keras: 在构建LSTM模型时,使用变长序列的方法

    众所周知,LSTM的一大优势就是其能够处理变长序列.而在使用keras搭建模型时,如果直接使用LSTM层作为网络输入的第一层,需要指定输入的大小.如果需要使用变长序列,那么,只需要在LSTM层前加一个 ...

  4. ruby 精选网站

    ruby 基础   http://www.yiibai.com/ruby/2013/0820174.html     http://www.rubydoc.info/github       http ...

  5. ASP.Net .Net4.0 HTTP 错误 404.17 - Not Found

    源:ASP.Net .Net4.0 HTTP 错误 404.17 - Not Found 用了网上很多方法,最后是用这个网友的方法解决的,在此做个记录. VS2010编写WebService与在IIS ...

  6. ubuntu16.04固定IP与设置DNS【转】

    本文转载自:http://www.jianshu.com/p/ea4bca38e5d7 学校几乎每次断电之后,宿舍的机器IP基本都会更改,即使可以通过图形界面去修改,但还是懒得去改.但是docker某 ...

  7. c语言学习的第11天 指针

    #include<stdio.h> int main(void) { int * p; int i=3; int j; p=&i; j=*p; printf("i=%d, ...

  8. 使用gdb调试c/c++代码

    转自 http://blog.csdn.net/haoel/article/details/2879 GDB概述———— GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具.或许,各位比较 ...

  9. 单元测试:TESTNG和powermock的使用

    pom文件: <properties>        <testng.version>6.8</testng.version>        <powermo ...

  10. L88

    Where You Vote May Affect How You Vote On election day, where do you vote? If it's in a church, you ...