Dividing a Chocolate zoj 2705

递推,找规律的题目:

具体思路见:http://blog.csdn.net/u010770930/article/details/9769333

 #include <stdio.h>
#include <iostream>
using namespace std;
int a[];
int main()
{
int i,j,maxx;
long long m,n;
a[]=;
a[]=;
while(~scanf("%lld%lld",&m,&n))
{
maxx=max(m,n);
for(i=;;i++)
{
a[i]=a[i-]+a[i-];
if(a[i]>maxx)
break;
}
for(j=i-;j>=;j--)
if(m%a[j]== || n%a[j]==)
{
cout<<m*n-m*n/a[j]<<endl<<endl;
break;
}
}
return ;
}

Dividing a Chocolate(zoj 2705)的更多相关文章

  1. POJ 1274 The Perfect Stall || POJ 1469 COURSES(zoj 1140)二分图匹配

    两题二分图匹配的题: 1.一个农民有n头牛和m个畜栏,对于每个畜栏,每头牛有不同喜好,有的想去,有的不想,对于给定的喜好表,你需要求出最大可以满足多少头牛的需求. 2.给你学生数和课程数,以及学生上的 ...

  2. 2014 牡丹江现场赛 A.Average Score(zoj 3819) 解题报告

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 题目意思: 有两个class:A 和 B,Bob 在 Clas ...

  3. 2014ACM/ICPC亚洲区域赛牡丹江站现场赛-I ( ZOJ 3827 ) Information Entropy

    Information Entropy Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Information ...

  4. POJ 1595 Prime Cuts (ZOJ 1312) 素数打表

    ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=312 POJ:http://poj.org/problem?id=159 ...

  5. POJ 2590 Steps (ZOJ 1871)

    http://poj.org/problem?id=2590 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1871 题目大 ...

  6. POJ 1065 Wooden Sticks(zoj 1025) 最长单调子序列

    POJ :http://poj.org/problem?id=1065 ZOJ: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId= ...

  7. 2013 ACM/ICPC 长沙现场赛 A题 - Alice's Print Service (ZOJ 3726)

    Alice's Print Service Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is providing print ser ...

  8. POJ 1775 (ZOJ 2358) Sum of Factorials

    Description John von Neumann, b. Dec. 28, 1903, d. Feb. 8, 1957, was a Hungarian-American mathematic ...

  9. UVALive 2522 Chocolate(概率DP)

    思路:定义DP方程dp[i][j]标记选到第i个巧克力的时候,桌面上还剩下j个巧克力,状态转移有两个方向,dp[i-1][j-1],dp[i-1]lj+1],分别表示桌面上多了一个和消了一个,乘上需要 ...

随机推荐

  1. mongodb查询返回内嵌符合条件的文档

    db.T_Forum_Thread.find({ "ThreadReply.ReplyContent" : /范甘迪/ }, { "ThreadReply.$" ...

  2. postman-根据接口文档进行测试

    根据接口文档来测试 1.get请求

  3. XidianOJ 1112 Too stupid

    题目描述 某天 light由于太富而且太帅遭到了歹徒的袭击,现在他遇到了n个歹徒,准备对light施行不法行为,虽然light身体强壮,但是毕竟只有一个人肯定打不过那么多歹徒,但是高智商的light觉 ...

  4. Linux_03------Linux的基本命令

    /** * 基本命令格式 * 命令 [选项] [参数] */ /** * 目录处理命令 * mkdir dirname 创建目录 * mkdir -p dir1/dir 递归创建目录 * cd dir ...

  5. 数据库中int类型存在空数据开发过程中model和dal层处理方法

    model层 public Int32? IsFullAttendance { get; set; } dal层  if (dr["IsFullAttendance"] + &qu ...

  6. 深入理解js——原型的灵活性

    在java中,class是一个模子,对象就是按照这个模子刻出来的:但是在JavaScript中对象可以刻成任意的样子. 首先,对象属性可以随时改动.对象或者函数,刚开始new出来之后,可能啥属性都没有 ...

  7. Rule of Modularity

    As Brian Kernighan once observed, “Controlling complexity is the essence of computer programming.” . ...

  8. The string "--" is not permitted within comments

    ibatis中SAXParseException异常:The string "--" is not permitted within comments 这个异常是说sqlmap里面 ...

  9. ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆AnalyzerTool分词工具.非常实用!

    AnalyzerTool分词工具.非常实用! 可以查看某串字符最终被分割成什么样子,这样便于查询时深刻明白为什么有的查不到有的却能查到. package com.isoftstone.www.tool ...

  10. 高版本Chrome不支持showModalDialog

    高版本Chrome不支持window.showModalDialog,可用window.open代替 var url = "https://www.baidu.com"; var ...