HDU 4925 Apple Tree

找规律

交错选择种植和施肥

当某一项为 1 的时候特判

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<map>
#define pi acos(-1.0)
#define eps 1e-8
#define ll long long
#define L 1000050
#define N 1050
#define Mod 1000000007
#define M 99999999999
#define clr(a) memset(a,0,sizeof(a))
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template<class T>
inline bool read(T &n)
{
    T x = 0, tmp = 1;
    char c = getchar();
    while((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar();
    if(c == EOF) return false;
    if(c == '-') c = getchar(), tmp = -1;
    while(c >= '0' && c <= '9') x *= 10, x += (c - '0'),c = getchar();
    n = x*tmp;
    return true;
}
template <class T>
inline void write(T n)
{
    if(n < 0)
    {
        putchar('-');
        n = -n;
    }
    int len = 0,data[20];
    while(n)
    {
        data[len++] = n%10;
        n /= 10;
    }
    if(!len) data[len++] = 0;
    while(len--) putchar(data[len]+48);
}

int main()
{
    int i,j,k,n;
    int cas=1;
    int a,b;
    //ios::sync_with_stdio(false);
    read(n);
    while(n--)
    {
        read(a),read(b);
        if(a==1&&b==1)
            printf("1\n");
        else
        {
            if(a>b)
                swap(a,b);
            if(a==1)
                printf("%d\n",2*(b-1));
            else
                printf("%d\n",(a-1)*(b-1)*8);
        }
        //printf("Case #%d: %d\n",cas++,res);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值