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

代码:

  1. //qscqesze
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <ctime>
  6. #include <iostream>
  7. #include <algorithm>
  8. #include <set>
  9. #include <vector>
  10. #include <sstream>
  11. #include <queue>
  12. #include <typeinfo>
  13. #include <fstream>
  14. #include <map>
  15. #include <stack>
  16. typedef long long ll;
  17. using namespace std;
  18. //freopen("D.in","r",stdin);
  19. //freopen("D.out","w",stdout);
  20. #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
  21. #define test freopen("test.txt","r",stdin)
  22. #define maxn 200000
  23. #define mod 10007
  24. #define eps 1e-9
  25. int Num;
  26. char CH[];
  27. const int inf=0x3f3f3f3f;
  28. const ll infll = 0x3f3f3f3f3f3f3f3fLL;
  29. inline ll read()
  30. {
  31. ll x=,f=;char ch=getchar();
  32. while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
  33. while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
  34. return x*f;
  35. }
  36. inline void P(int x)
  37. {
  38. Num=;if(!x){putchar('');puts("");return;}
  39. while(x>)CH[++Num]=x%,x/=;
  40. while(Num)putchar(CH[Num--]+);
  41. puts("");
  42. }
  43. //**************************************************************************************
  44.  
  45. int main()
  46. {
  47. int t=read();
  48. while(t--)
  49. {
  50. ll a=read(),b=read();
  51. cout<<a*b-<<endl;
  52. }
  53. }

cdoj 48 Cake 水题的更多相关文章

  1. 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 ...

  2. hdu 5284 BestCoder Round #48 ($) 1001 水题 *

    题意:看一个字符串中是否包含顺序的  w  y  h ,字符之间可以有其他字符,并且如果有多个连续的vv,则可以看做一个w 比较水,直接看代码 #include<cstdio> #incl ...

  3. hdu-5640 King's Cake (水题)

    题目链接 King's Cake Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others ...

  4. cdoj 80 Cube 水题

    Cube Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/80 Descrip ...

  5. cdoj 26 遮挡判断(shadow) 水题

    遮挡判断(shadow) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/26 ...

  6. cdoj 24 8球胜负(eight) 水题

    8球胜负(eight) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/24 ...

  7. hdu 2044:一只小蜜蜂...(水题,斐波那契数列)

    一只小蜜蜂... Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepte ...

  8. 【BZOJ】初级水题列表——献给那些想要进军BZOJ的OIers(自用,怕荒废了最后的六月考试月,刷刷水题,水水更健康)

    BZOJ初级水题列表——献给那些想要进军BZOJ的OIers 代码长度解释一切! 注:以下代码描述均为C++ RunID User Problem Result Memory Time Code_Le ...

  9. PAT甲题题解-1050. String Subtraction (20)-水题

    #include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...

随机推荐

  1. 利用DescriptionAttribute定义枚举值的描述信息 z

    System.ComponentModel命名空间下有个名为DescriptionAttribute的类用于指定属性或事件的说明,我所调用的枚举值描述信息就是DescriptionAttribute类 ...

  2. Delphi RxRichEdit高级操作

    unit InsertRichEditUnit;interfaceuses  Windows, Messages, SysUtils, Classes, Graphics, Controls, For ...

  3. ORA-12516: TNS: 监听程序无法找到匹配协议栈的可用句柄解决方法

    1.查看当前连接进程数SQL>select count(*) from v$process;2.查看连接数上限SQL>select value from v$parameter where ...

  4. Python的pep8(代码规范)

    Python的pep8-代码规范 1.    代码布局设计 1.1    缩进 A.   使用四个空格来进行缩进 B.   换行的时候可以使用反斜杠,最好的方法是使用园括号,在使用反斜杠的时候,在反斜 ...

  5. TopFreeTheme精选免费模板【20130619】

    今天给大家推荐7款最新精选的WordPress主题和一个WooCommerce订单跟踪插件,如果你有更换自己博客主题的想法或者正要做自己的博客,不妨试试.一些是WordPress商业模板,但都可以免费 ...

  6. MySql 5.6 查询日志

    记录所有查询的方法 打开My.ini 在 [mysqld]下面写 general_log= ON; log_output= TABLE; 然后保存重启mysql 最后在mysql库下 general_ ...

  7. 在Cubieboard上关闭irqbalance服务避免内存泄漏

    十一一个假期回来,顺手看了看自己的cubieboard运行状态怎么样 aria2正常: btsync正常: samba正常: 很好, 顺手htop一下,已经开机了13天了,CPU使用率4%,内存使用率 ...

  8. 事件委托(event delegation)

    事件委托给我带来的第一印象是,如果可以的话请尝试得经常使用它,性能好! 通过字符串拼接后,并进行DOM插入,不会复制事件,此时需要进行事件委托了!!! 优点 事件委托对于web应用程序的性能有如下几个 ...

  9. 在IT网站上少花些时间

    我自己关注的IT网站还是蛮多的,经常去的有CSDN,博客园,51CTO,InfoQ,还有微博,微信上关注了IT程序猿,IT技术博客大学习,程序员之家, 开发者头条,还有还有,我还通过邮件订阅了码家周刊 ...

  10. 使用avalon 实现一个订座系统

    avalon对交互非常复杂的WEB应用具有天然的优势,它拥有两大神器:计算属性(这相当于后端WPF的DependencyProperty)与$watch回调. 我们的订餐系统的要求如下,它有一个总额统 ...