cdoj 48 Cake 水题
Cake
Time Limit: 20 Sec Memory Limit: 256 MB
题目连接
http://acm.uestc.edu.cn/#/problem/show/48
Description
ZC's birthday is comming, lxh gives a cake of n×m as present for his girlfriend.Now lxh wants to know how many second do you need to divide it to many 1×1 cakes? Every second you can choose a connected part of cake, and cut it into two along a straight line.
Input
In the first line, an integer T is given indects the number of test case.
For each case, you can get two interger n and m in the line. (n,m≤109)
Output
For each case, output the answer in a line.
Sample Input
2
1 1
2 2
Sample Output
0
3
HINT
题意
题解:
答案是a*b-1,会爆int
代码:
- //qscqesze
- #include <cstdio>
- #include <cmath>
- #include <cstring>
- #include <ctime>
- #include <iostream>
- #include <algorithm>
- #include <set>
- #include <vector>
- #include <sstream>
- #include <queue>
- #include <typeinfo>
- #include <fstream>
- #include <map>
- #include <stack>
- typedef long long ll;
- using namespace std;
- //freopen("D.in","r",stdin);
- //freopen("D.out","w",stdout);
- #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
- #define test freopen("test.txt","r",stdin)
- #define maxn 200000
- #define mod 10007
- #define eps 1e-9
- int Num;
- char CH[];
- const int inf=0x3f3f3f3f;
- const ll infll = 0x3f3f3f3f3f3f3f3fLL;
- inline ll read()
- {
- ll x=,f=;char ch=getchar();
- while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
- while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
- return x*f;
- }
- inline void P(int x)
- {
- Num=;if(!x){putchar('');puts("");return;}
- while(x>)CH[++Num]=x%,x/=;
- while(Num)putchar(CH[Num--]+);
- puts("");
- }
- //**************************************************************************************
- int main()
- {
- int t=read();
- while(t--)
- {
- ll a=read(),b=read();
- cout<<a*b-<<endl;
- }
- }
cdoj 48 Cake 水题的更多相关文章
- Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题
A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Do ...
- hdu 5284 BestCoder Round #48 ($) 1001 水题 *
题意:看一个字符串中是否包含顺序的 w y h ,字符之间可以有其他字符,并且如果有多个连续的vv,则可以看做一个w 比较水,直接看代码 #include<cstdio> #incl ...
- hdu-5640 King's Cake (水题)
题目链接 King's Cake Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- cdoj 80 Cube 水题
Cube Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/80 Descrip ...
- cdoj 26 遮挡判断(shadow) 水题
遮挡判断(shadow) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/26 ...
- cdoj 24 8球胜负(eight) 水题
8球胜负(eight) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/24 ...
- hdu 2044:一只小蜜蜂...(水题,斐波那契数列)
一只小蜜蜂... Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepte ...
- 【BZOJ】初级水题列表——献给那些想要进军BZOJ的OIers(自用,怕荒废了最后的六月考试月,刷刷水题,水水更健康)
BZOJ初级水题列表——献给那些想要进军BZOJ的OIers 代码长度解释一切! 注:以下代码描述均为C++ RunID User Problem Result Memory Time Code_Le ...
- PAT甲题题解-1050. String Subtraction (20)-水题
#include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...
随机推荐
- 利用DescriptionAttribute定义枚举值的描述信息 z
System.ComponentModel命名空间下有个名为DescriptionAttribute的类用于指定属性或事件的说明,我所调用的枚举值描述信息就是DescriptionAttribute类 ...
- Delphi RxRichEdit高级操作
unit InsertRichEditUnit;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, For ...
- ORA-12516: TNS: 监听程序无法找到匹配协议栈的可用句柄解决方法
1.查看当前连接进程数SQL>select count(*) from v$process;2.查看连接数上限SQL>select value from v$parameter where ...
- Python的pep8(代码规范)
Python的pep8-代码规范 1. 代码布局设计 1.1 缩进 A. 使用四个空格来进行缩进 B. 换行的时候可以使用反斜杠,最好的方法是使用园括号,在使用反斜杠的时候,在反斜 ...
- TopFreeTheme精选免费模板【20130619】
今天给大家推荐7款最新精选的WordPress主题和一个WooCommerce订单跟踪插件,如果你有更换自己博客主题的想法或者正要做自己的博客,不妨试试.一些是WordPress商业模板,但都可以免费 ...
- MySql 5.6 查询日志
记录所有查询的方法 打开My.ini 在 [mysqld]下面写 general_log= ON; log_output= TABLE; 然后保存重启mysql 最后在mysql库下 general_ ...
- 在Cubieboard上关闭irqbalance服务避免内存泄漏
十一一个假期回来,顺手看了看自己的cubieboard运行状态怎么样 aria2正常: btsync正常: samba正常: 很好, 顺手htop一下,已经开机了13天了,CPU使用率4%,内存使用率 ...
- 事件委托(event delegation)
事件委托给我带来的第一印象是,如果可以的话请尝试得经常使用它,性能好! 通过字符串拼接后,并进行DOM插入,不会复制事件,此时需要进行事件委托了!!! 优点 事件委托对于web应用程序的性能有如下几个 ...
- 在IT网站上少花些时间
我自己关注的IT网站还是蛮多的,经常去的有CSDN,博客园,51CTO,InfoQ,还有微博,微信上关注了IT程序猿,IT技术博客大学习,程序员之家, 开发者头条,还有还有,我还通过邮件订阅了码家周刊 ...
- 使用avalon 实现一个订座系统
avalon对交互非常复杂的WEB应用具有天然的优势,它拥有两大神器:计算属性(这相当于后端WPF的DependencyProperty)与$watch回调. 我们的订餐系统的要求如下,它有一个总额统 ...