思路:

根据案例的规律其实已经猜的差不多了,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. UVa 10828 Back to Kernighan-Ritchie 高斯消元+概率DP

    题目来源:UVa 10828 Back to Kernighan-Ritchie 题意:从1開始 每次等概率从一个点到和他相邻的点 有向 走到不能走停止 求停止时每一个点的期望 思路:写出方程消元 方 ...

  2. ceph pool 管理

    创建池 [root@node1 ~]# ceph osd pool create monitor pool 'monitor' created 查看池 [root@node1 ~]# ceph osd ...

  3. Java for LeetCode 101 Symmetric Tree

    Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For e ...

  4. ZOJ - 3861 Valid Pattern Lock 【全排列】

    题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3861 思路 先生成全排列,然后判断哪些情况不符合的,剔除就好了 ...

  5. debian7 amd64版本添加对x86包的支持

    dpkg --add-architecture i386apt-get updateapt-get install ia32-libs ia32-libs-gtk

  6. 打开Vs2010时,卡在加载工具箱内容 不动了

    我是直接打开Visual Studio 2010,而不是以打开解决方案的方式打开.然后就在左下角显示“正在从包‘Microsoft.VisualStudio.IDE.ToolboxControlsIn ...

  7. 验证控件 .net

    检查Page.IsValid   if (typeof (Page_ClientValidate) == 'function') {                Page_ClientValidat ...

  8. ZOJ3228 Searching the String —— AC自动机 + 可重叠/不可重叠

    题目链接:https://vjudge.net/problem/ZOJ-3228 Searching the String Time Limit: 7 Seconds      Memory Limi ...

  9. 理解SQL原理,写出高效的SQL语句

    我们做软件开发的,大部分人都离不开跟数据库打交道,特别是erp开发的,跟数据库打交道更是频繁,存储过程动不动就是上千行,如果数据量大,人员流动大,那么我们还能保证下一段时间系统还能流畅的运行吗?我们还 ...

  10. Springboot2.0入门介绍

    Springboot目前已经得到了很广泛的应用,why这么牛逼? Springboot让你更容易上手,简单快捷的构建Spring的应用 Spring Boot让我们的Spring应用变的更轻量化.比如 ...