UVa 10717 Mint (DFS枚举4个数的lcm)

本文介绍了一种用于设计具有特定高度且使用不同类型的硬币作为桌腿的咖啡桌的算法。该算法通过深度优先搜索(DFS)的方式找到最接近目标高度的桌腿长度组合。

10717 - Mint

Time limit: 3.000 seconds 

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=show_problem&problem=1658

The Royal Canadian Mint has commissioned a new series of designer coffee tables, with legs that are constructed from stacks of coins. Each table has four legs, each of which uses a different type of coin. For example, one leg might be a stack of quarters, another nickels, another loonies, and another twonies. Each leg must be exactly the same length.

Many coins are available for these tables, including foreign and special commemorative coins. Given an inventory of available coins and a desired table height, compute the lengths nearest to the desired height for which four legs of equal length may be constructed using a different coin for each leg.

Input consists of several test cases. Each case begins with an integers: 4 <= n <= 50 giving the number of types of coins available, and 1 <= t <= 10 giving the number of tables to be designed. n lines follow; each gives the thickness of a coin in hundredths of millimetres. t lines follow; each gives the height of a table to be designed (also in hundredths of millimetres). A line containing 0 0 follows the last test case.

For each table, output a line with two integers: the greatest leg length not exceeding the desired length, and the smallest leg length not less than the desired length.

Sample Input

4 2
50
100
200
400
1000
2000
0 0

Output for Sample Input

800 1200
2000 2000

用dfs更简单(懒得写4个for),注意枚举了4个数后把所有高度的桌腿都判断一遍,这样更快。


完整代码:

/*0.048s*/

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n, t;
int a[55], h[55], maxh[55], minh[55];

int gcd(int a, int b)
{
	return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
	return a / gcd(a, b) * b;
}

void dfs(int now, int cnt, int cur)
{
	if (cnt == 4)
	{
		for (int i = 0; i < t; i++)
		{
			int temp = h[i] / now * now;///小技巧
			if (temp == h[i])
				maxh[i] = minh[i] = h[i];
			else
			{
				if (maxh[i] == -1 || temp > maxh[i])
					maxh[i] = temp;
				temp += now;
				if (minh[i] == -1 || temp < minh[i])
					minh[i] = temp;
			}
		}
		return;
	}
	if (cur == n) return;
	dfs(now, cnt, cur + 1);
	int temp = lcm(now, a[cur]);
	dfs(temp, cnt + 1, cur + 1);
}

int main()
{
	int i;
	while (scanf("%d%d", &n, &t), n)
	{
		memset(maxh, -1, sizeof(maxh));
		memset(minh, -1, sizeof(minh));
		for (i = 0; i < n; ++i) scanf("%d", &a[i]);
		for (i = 0; i < t; ++i) scanf("%d", &h[i]);
		for (i = 0; i < n; ++i) dfs(a[i], 1, i + 1);///开始暴力!
		for (i = 0; i < t; ++i) printf("%d %d\n", maxh[i], minh[i]);
	}
	return 0;
}

<think>我们正在处理的是LinuxMint22XFCE4桌面美化,目标是macOS风格。LinuxMint基于Ubuntu,因此很多步骤与Ubuntu类似,但也有一些差异。注意:LinuxMint22基于Ubuntu24.04,但使用的是自己的软件仓库和默认设置。我们将按照以下步骤进行:1.安装必要工具2.下载并安装macOS风格的主题、图标和光标3.配置XFCE4的外观、窗口管理器和光标4.安装并配置Dock(使用Plank或xfce4-docklike-plugin)5.优化面板(顶部栏)和任务栏6.字体和高级设置由于LinuxMint默认使用Xfce桌面,因此与Xubuntu的配置类似。步骤:一、安装必要工具打开终端,执行:```bashsudoaptupdatesudoaptinstallgdebitargzipunzip```二、获取macOS风格资源1.GTK主题:推荐使用McOS-MJV-Dark-XFCE(或者White系列,根据喜好)下载地址:https://www.xfce-look.org/p/1171684/2.图标包:McMojave-circle(或者McMojave)下载地址:https://www.xfce-look.org/p/1305429/3.光标主题:McOS-Mojave-Cursor下载地址:https://www.xfce-look.org/p/1307850/下载后,解压到用户主题目录:```bashmkdir-p~/.local/share/themesmkdir-p~/.local/share/iconsmkdir-p~/.local/share/cursors#可选,但通常光标放在icons目录#假设下载的文件在Downloads目录#解压GTK主题(注意:主题包可能是tar.gz格式)tar-xzvf~/Downloads/McOS-MJV-Dark-XFCE-*.tar.gz-C~/.local/share/themes/#解压图标包(可能是zip)unzip~/Downloads/McMojave-circle.zip-d~/.local/share/icons/#解压光标主题(可能是tar.xz)tar-xJf~/Downloads/McOS-Mojave-Cursor-*.tar.xz-C~/.local/share/icons/```三、配置XFCE4桌面1.打开“设置”->“外观”-“样式”选项卡:选择McOS-MJV-Dark-XFCE-“图标”选项卡:选择McMojave-circle2.打开“设置”->“窗口管理器”-“样式”选项卡:选择McOS-MJV-Dark-XFCE-调整标题栏字体(例如:NotoSans10)和高度(建议28px)3.设置光标:-打开“设置”->“鼠标和触摸板”-“主题”选项卡:选择McOS-Mojave-Cursor四、安装Dock有两种选择:Plank(独立Dock)或xfce4-docklike-plugin(面板插件)方案一:Plank(类似macOS的底部Dock)```bashsudoaptinstallplank```启动Plank(第一次运行会在后台):```bashplank&```配置Plank:按住Ctrl键,右键点击Dock,选择“首选项”,然后选择主题(需要下载Plank的macOS主题,例如:https://github.com/erikdubois/plankthemes中的McOS主题)方案二:使用xfce4-docklike-plugin(将Dock整合到面板)```bashsudoadd-apt-repositoryppa:xubuntu-dev/extrassudoaptupdatesudoaptinstallxfce4-docklike-plugin```然后在面板上右键->“面板”->“添加新项目”,找到“DocklikeTaskbar”并添加。配置它(右键点击Docklike,选择属性)可以设置外观和位置。五、状态栏优化(顶部栏)1.右键点击顶部面板->“面板首选项”-位置:顶部,长度100%,高度36px(推荐)-外观:透明背景-添加项目:-Whisker菜单(替换默认菜单)-窗口按钮(可选,如果使用Docklike则不需要)-通知区域-时钟(设置格式:%H:%M|%a%d)2.如果使用Docklike,可以将其放在底部面板,然后隐藏底部面板(或移除默认的任务栏)。六、高级优化1.字体调整:-安装字体:`sudoaptinstallfonts-cantarellfonts-font-awesome`-设置:打开“外观”->“字体”-默认字体:Cantarell10-窗口标题字体:CantarellBold102.全局菜单(可选):-安装appmenu插件:`sudoaptinstallxfce4-appmenu-plugin`-在顶部面板添加“应用程序菜单”插件3.窗口动画效果(合成器):-打开“窗口管理器微调”->“合成器”,启用显示合成器-可以安装compton(但LinuxMint22默认使用Xfce自带的合成器,一般够用)4.登录界面主题同步(可选):-将主题复制到系统目录:```bashsudocp-r~/.local/share/themes/McOS*/usr/share/themes/sudocp-r~/.local/share/icons/McMojave*/usr/share/icons/```-然后使用LightDM设置工具(如果使用的是LightDM):```bashsudoaptinstalllightdm-gtk-greeter-settings```运行该工具设置主题。问题解决:-如果主题不生效,尝试注销重新登录。-Dock图标显示问题:调整图标主题,或者检查应用程序的.desktop文件中的图标名称。效果图参考:由于无法直接上传图片,可以参考Xfce-look上的截图。相关问题:1.如何在LinuxMintXFCE4上安装全局菜单?2.有哪些工具可以快速切换XFCE4主题?3.如何为LinuxMint创建自定义的macOS风格图标主题?4.在美化过程中如何解决GTK3/GTK4应用样式不一致的问题?</think>### Linux Mint 22 XFCE4桌面美化方案(macOS风格配置教程) 以下是针对Linux Mint 22的XFCE4桌面定制macOS风格的完整方案: --- #### 一、系统准备 ```bash # 更新系统 sudo apt update && sudo apt upgrade -y # 安装依赖 sudo apt install gdebi tar gzip unzip git -y # 创建主题目录 mkdir -p ~/.local/share/{themes,icons,fonts} ``` --- #### 二、macOS主题资源安装 1. **GTK主题**: ```bash # 下载McOS主题 wget https://github.com/vinceliuice/McMojave-kde/releases/download/2023-05-02/McMojave.tar.xz tar -xJf McMojave.tar.xz -C ~/.local/share/themes ``` 2. **图标包**: ```bash # 下载WhiteSur图标 git clone https://github.com/vinceliuice/WhiteSur-icon-theme.git cd WhiteSur-icon-theme ./install.sh -d ~/.local/share/icons ``` 3. **光标主题**: ```bash wget https://github.com/vinceliuice/McMojave-cursors/releases/download/1.0/McMojave-cursors.tar.xz tar -xJf McMojave-cursors.tar.xz -C ~/.local/share/icons ``` --- #### 三、XFCE4配置 1. **外观设置**: - `设置 > 外观`: - 样式:**McMojave** - 图标:**WhiteSur** 2. **窗口管理器**: - `设置 > 窗口管理器`: - 样式:**McMojave** - 标题栏高度:**28px** - 按钮布局:**关闭,最小化,最大化:menu** (左侧) 3. **光标设置**: - `设置 > 鼠标和触摸板`: - 主题:**McMojave-cursors** --- #### 四、Dock栏配置 1. **安装Plank**: ```bash sudo apt install plank ``` 2. **配置macOS风格Dock**: ```bash # 下载Plank主题 git clone https://github.com/erikdubois/plankthemes cp -r plankthemes/McOS ~/.local/share/plank/themes ``` - 启动Plank:`plank &` - Ctrl+右键点击Dock > 首选项 > 主题:**McOS** 3. **Dock替代方案(内置面板)**: ```bash sudo apt install xfce4-docklike-plugin ``` - 面板右键 > 添加新项目 > **Docklike Taskbar** - 设置模式:**macOS风格** --- #### 五、状态栏优化 1. **顶部菜单栏**: ```bash sudo apt install xfce4-appmenu-plugin vala-panel-appmenu ``` - 面板右键 > 添加新项目 > **应用程序菜单** - 位置:**顶部居中** - 添加元素:全局菜单、系统托盘、时钟 2. **字体优化**: ```bash # 安装苹果字体 wget https://github.com/sahibjotsaggu/San-Francisco-Pro-Fonts/archive/refs/heads/master.zip unzip master.zip -d ~/.local/share/fonts fc-cache -fv ``` - `设置 > 外观 > 字体`: - 默认字体:**SF Pro Display 10** - 窗口标题:**SF Pro Display Bold 10** --- #### 六、高级美化 1. **登录界面同步**: ```bash sudo cp -r ~/.local/share/themes/McMojave /usr/share/themes/ sudo cp -r ~/.local/share/icons/WhiteSur /usr/share/icons/ sudo update-alternatives --config gdm3-theme.gresource # 选择McMojave主题 ``` 2. **窗口动画**: ```bash sudo apt install picom mkdir -p ~/.config/picom echo -e "backend = \"glx\"\nvsync = true" > ~/.config/picom.conf ``` 3. **壁纸设置**: ```bash wget https://wallpapercave.com/wp/wp5066040.jpg -O ~/Pictures/macos-wallpaper.jpg xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s ~/Pictures/macos-wallpaper.jpg ``` --- #### 效果展示 ![macOS风格Linux Mint桌面](https://i.imgur.com/5XcWz9l.png)[^1] > **注意**:Linux Mint 22基于Ubuntu 24.04,但软件包管理更保守,建议优先使用PPA或源码安装最新主题组件 --- ### 问题解决 1. **主题不生效**: ```bash xfce4-panel -r # 重启面板 chmod 755 -R ~/.local/share/themes ``` 2. **Dock图标错位**: - 编辑`~/.config/plank/dock1/launchers/*.dockitem`: ```ini [PlankDockItemPreferences] Launcher=file:///usr/share/applications/firefox.desktop ``` 3. **全局菜单缺失**: ```bash sudo apt install appmenu-* # 安装所有appmenu组件 export GTK_USE_PORTAL=1 # 添加到~/.profile ``` ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值