bzoj 1024 [ SCOI 2009 ] 生日快樂 —— 遞歸

題目:https://www.lydsy.com/JudgeOnline/problem.php?id=1024

因為每次把一塊切成兩塊,所以可以枚舉從哪里切開,然后遞歸求解;

一開始用了不太對的貪心思路,想著一定去切較長邊,但看來不一定。

代碼如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int inf=1e9;
int a,b,n;
double ans=inf,s;
double dfs(double x,double y,int cnt)
{
//    printf("x=%.2lf y=%.2lf cnt=%d\n",x,y,cnt);if(x<y)swap(x,y);double ret=inf;if(cnt==1)return x/y;for(int i=1;i<cnt;i++){
//        double k=(x*y-i*s)/y;double k=x*i/cnt;ret=min(ret,max(dfs(k,y,i),dfs(x-k,y,cnt-i)));
//        k=(x*y-i*s)/x;k=y*i/cnt;ret=min(ret,max(dfs(x,k,i),dfs(x,y-k,cnt-i)));}return ret;
}
int main()
{scanf("%d%d%d",&a,&b,&n);s=1.0*a*b/n;if(a<b)swap(a,b);
//    for(int i=1;i<n;i++)
//    {
//        double k=(1.0*a*b-i*s)/b;
//        ans=min(ans,max(dfs(k,b,n-i),dfs(a-k,b,i)));
//    }printf("%.6lf",dfs(a,b,n));return 0;
}

?

轉載于:https://www.cnblogs.com/Zinn/p/9378242.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/279744.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/279744.shtml
英文地址,請注明出處:http://en.pswp.cn/news/279744.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

HBase存儲剖析與數據遷移

1.概述 HBase的存儲結構和關系型數據庫不一樣&#xff0c;HBase面向半結構化數據進行存儲。所以&#xff0c;對于結構化的SQL語言查詢&#xff0c;HBase自身并沒有接口支持。在大數據應用中&#xff0c;雖然也有SQL查詢引擎可以查詢HBase&#xff0c;比如Phoenix、Drill這類。但…

windows os x_如何立即在OS X上獲取Windows樣式的窗口捕捉

windows os xApple’s recent announcement that the upcoming OS X release (El Capitan or 10.11) will finally, at long last, come with the ability to snap windows to your screen edges. A feature Windows users have enjoyed since 2009. 蘋果公司最近宣布即將發布的…

Install Odoo 11 on CentOS 7

2019獨角獸企業重金招聘Python工程師標準>>> Odoo is the most popular all-in-one business software in the world. It offers a range of business applications including CRM, website, e-Commerce, billing, accounting, manufacturing, warehouse, project m…

創建maven項目,配置maven地址

2019獨角獸企業重金招聘Python工程師標準>>> 在eclipse中&#xff0c;新建maven項目next第二步&#xff0c;選擇webapp輸入id及包名&#xff0c;完成新建給項目build path&#xff0c;添加1.8版本jdk和tomcat項目右鍵屬性 project Facets&#xff0c;切換成web項目&…

如何在Excel中隱藏單元格,行和列

There may be times when you want to hide information in certain cells or hide entire rows or columns in an Excel worksheet. Maybe you have some extra data you reference in other cells that does not need to be visible. 有時您可能想在某些單元格中隱藏信息或在…

金三銀四,跳槽為敬

不是不想跳&#xff0c;是如今的市場水冷&#xff0c;挪不開腳。 三月有“黃金”。 過去很多年&#xff0c;這個被譽為市場黃金期的階段&#xff0c;最熱鬧的旗幟屬于房地產&#xff0c;其次是人才市場。跳槽二字&#xff0c;充滿誘惑。對每一個想要改變的人而言&#xff0c;…

yum搭建本地倉庫、國內源、下載rpm包、源碼安裝

yum搭建本地倉庫[rootlocalhost ~]# mount /dev/cdrom /mnt/mount: /dev/sr0 寫保護&#xff0c;將以只讀方式掛載cp -r /etc/yum.repos.d /etc/yum.repos.d.bak[rootlocalhost ~]# cp -r /etc/yum.repos.d/ /etc/yum.repos.d.ori/ //復制rm -f /etc/yum.repos.d/*[rootlocalh…

如何在Word文檔中添加頁眉或頁腳

Headers and footers are useful for adding things such as page numbers, dates, file names, and disclaimers to documents. Word allows you to add headers and footers with built-in, ready-made layouts or add your own custom headers and footers. 頁眉和頁腳對于在…

python基礎知識-8-三元和一行代碼(推導式)

python其他知識目錄 1、三元運算&#xff08;三目運算&#xff09; 三元運算符就是在賦值變量的時候&#xff0c;可以直接加判斷&#xff0c;然后賦值格式&#xff1a;[on_true] if [expression] else [on_false]res 值1 if 條件 else 值2 其他語言類似結構&#xff1a;判段的…

雙11成交多少和我無關,但這個魔性MV真的讓我笑噴!

今年天貓雙11&#xff0c;印象最深的就是“祝你雙11快樂”這句話&#xff01;它讓大家感覺到雙11不再只是一個購物節&#xff0c;而是一個能引起廣泛共鳴、讓大家有快樂情感的真正節日。以往的傳統節日&#xff0c;都有一個標志性的符號&#xff0c;正如腦海中的每年春晚&#…

ios beta 下載_如何回滾到iOS 10(如果您使用的是iOS 11 Beta)

ios beta 下載So you’ve installed the iOS 11 beta and, well, you don’t love it. No problem, because you can roll right back to iOS 10. 因此&#xff0c;您已經安裝了iOS 11 Beta &#xff0c;但是&#xff0c;您不喜歡它。 沒問題&#xff0c;因為您可以直接回滾到i…

JmsTemplate sendAndReceive 設置超時

通過調用sendAndReceive方法&#xff0c;實現發送消息之后可以同步接收返回信息。 Message replyMsg this.jmsQueueTemplate.sendAndReceive(new MessageCreator(){Overridepublic Message createMessage(Session sn) throws JMSException {TextMessage txtMsg sn.createText…

亞信科技數據庫AntDB通過金融分布式事務數據庫標準測試

近日,南京, 中國信息通信研究院云計算與大數據研究所(以下簡稱“中國信通院云大所”)組織專家對亞信科技(股票代碼:01675.HK)的數據庫產品AISWare AntDB(以下簡稱“AntDB”),進行了金融分布式事務數據庫標準測試,所有功能順利通過測試。該測試的通過充分彰顯了亞信科技AntDB是一…

安裝sql2012 需要安裝net3.5 沒有的話 安裝不成功

Error while enabling Windows feature : NetFx3, Error Code : -2146498298 在 Windows 8 或 Windows Server 2012 中安裝 .NET Framework 3.5 時出現錯誤代碼&#xff1a;0x800F0906 winx 管理員權限 打開cmd命令提示符處&#xff0c;運行下面的命令&#xff1a; Dism /onl…

instagram發布工具_如何在不發布照片的情況下保存已編輯的Instagram照片

instagram發布工具Unfortunately, there’s no built-in method for saving your edited Instagram photos without posting them first. However, with this neat trick, you can add Instagram filters to your photos and save them locally to your phone without actually…

Verify the Developer App certificate for your account is trusted on your device.

1、報錯內容 Could not launch “CH5203” Verify the Developer App certificate for your account is trusted on your device. Open Settings on 測試 and navigate to General -> Device Management, then select your Developer App certificate to trust it. 2、解決方…

HTTP2和HTTPS來不來了解一下?

一、前言 只有光頭才能變強 HTTP博文回顧&#xff1a; PC端&#xff1a;HTTP就是這么簡單PC端&#xff1a;HTTP面試題都在這里微信公眾號端&#xff1a;HTTP就是這么簡單微信公眾號端&#xff1a;HTTP面試題都在這里本文力求簡單講清每個知識點&#xff0c;希望大家看完能有所收…

apple默認備份位置_如何將Apple Maps默認設置為步行路線

apple默認備份位置The default mode of transportation in Apple Maps is set to driving, but with a simple tweak, you can adjust your Apple Maps experience to default to the mode you use most. Apple Maps中的默認交通方式設置為行車&#xff0c;但是通過簡單的調整&…

php 面向對象

1類的創建 class創建類 class Person{} 2.對象的創建 使用new關鍵字 class Person{} $p1new Person 3.成員的添加 添加成員需要 三個修飾符 public 公開的 定義公共的屬性和方法&#xff0c;類的外部&#xff0c;類的內部&#xff0c;子類都可以使用 protected 受保護的 定義…

apache 404\403錯誤頁面跳轉

1、全局下使用404跳轉 在httpd.conf下配置跳轉 1vim /usr/local/httpd/conf/httpd.conf 123456<Directory "/usr/local/httpd-2.4.25/htdocs"> AllowOverride None Require all granted ErrorDocument 404 /aa.jpg #配置跳轉頁面&#xff0c;注意aa文件必須在…