//
// main.cpp
// Richard
//
// Created by 邵金杰 on 16/10/3.
// Mail:1016427040@qq.com or jasonshaosjj@gmail.com
// Copyright © 2016年 邵金杰. All rights reserved.
//
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int dfs(int r,int c)
{
if(r==1) return c-1;
if(r%2==0) return dfs(r/2,c)+dfs(r/2,c)+1;
else return dfs(1,c)+dfs(r-1,c)+1;
}
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
if(n>m) swap(n,m);
printf("%d\n",dfs(n,m));
}
return 0;
}
UVA 10970 Big Chocolate(水题)
最新推荐文章于 2020-03-01 23:33:55 发布