839 - Not so Mobile

  Not so Mobile 

Before being an ubiquous communications gadget, a mobile was just a structure made of strings and wires suspending colourfull things. This kind of mobile is usually found hanging over cradles of small babies.

\epsfbox{p839a.eps}

The figure illustrates a simple mobile. It is just a wire, suspended by a string, with an object on each side. It can also be seen as a kind of lever with the fulcrum on the point where the string ties the wire. From the lever principle we know that to balance a simple mobile the product of the weight of the objects by their distance to the fulcrum must be equal. That is Wl×Dl = Wr×Dr where Dl is the left distance, Dr is the right distance, Wl is the left weight and Wr is the right weight.


In a more complex mobile the object may be replaced by a sub-mobile, as shown in the next figure. In this case it is not so straightforward to check if the mobile is balanced so we need you to write a program that, given a description of a mobile as input, checks whether the mobile is in equilibrium or not.

\epsfbox{p839b.eps}

Input 

The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.


The input is composed of several lines, each containing 4 integers separated by a single space. The 4 integers represent the distances of each object to the fulcrum and their weights, in the format: Wl Dl Wr Dr

If Wl or Wr is zero then there is a sub-mobile hanging from that end and the following lines define the the sub-mobile. In this case we compute the weight of the sub-mobile as the sum of weights of all its objects, disregarding the weight of the wires and strings. If both Wl and Wr are zero then the following lines define two sub-mobiles: first the left then the right one.

Output 

For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.


Write `YES' if the mobile is in equilibrium, write `NO' otherwise.

Sample Input 

1

0 2 0 4
0 3 0 1
1 1 1 1
2 4 4 2
1 6 3 2

Sample Output 

YES

由于二叉树的建立可以用递归来实现。所以和二叉树相关的题目,都能够读出递归的味道。

这道题是一个系统,要求能够达到杠杆平衡。每一组为一个单位,那其左侧和右侧有可以再次分为两个小的平衡体来做。


#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
using namespace std;
bool uq=true;
int input()
{
    int w1,d1,w2,d2;
    cin>>w1>>d1>>w2>>d2;
    if (w1==0)
        w1+=input();
    if (w2==0)
        w2+=input();
    if (w1*d1!=w2*d2) uq=false;
    return w1+w2;
}
int main ()
{
    int n;
    cin>>n;
    while(n--)
    {
        uq=true;
        input();
        if (uq) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        if (n!=0) cout<<endl;
    }
}



<think>嗯,用户遇到了OpenCV链接错误,具体是libopencv_stitching.so.4.5.4d文件格式不被识别的问题。我需要先分析可能的原因。根据引用中的信息,用户可能安装了多个OpenCV版本,导致链接时版本冲突。比如引用[2]提到用户同时有OpenCV-4.2.0和4.5.4,而cv_bridge可能链接到错误版本。 首先,检查CMakeLists.txt中的OpenCV配置是否正确。确保find_package(OpenCV REQUIRED)能找到正确的版本,并且include和lib路径指向预期的安装位置。用户可能在编译时指定了错误版本的OpenCV,或者环境变量如PKG_CONFIG_PATH没有正确设置,如引用[4]中的问题,缺少opencv.pc文件路径。 其次,验证OpenCV安装是否完整。可能需要重新编译安装OpenCV,并确保所有模块正确生成。引用[5]中的opencv4.pc内容显示库版本为4.5.5,可能用户安装的版本不一致,或者编译选项有问题。 另外,检查系统架构是否一致,比如x86_64的库被用在arm架构上,或者反之,导致文件格式不识别。引用[3]中提到了aarch64的路径,可能存在交叉编译的问题。用户需要确认编译环境和目标平台是否匹配。 还有,清理CMake缓存,避免旧配置干扰。有时候之前的错误配置会导致链接错误,重新生成构建目录可能有帮助。 最后,确保动态库路径正确。使用ldconfig更新库缓存,或者设置LD_LIBRARY_PATH环境变量指向正确的OpenCV库目录。如果用户自定义安装了OpenCV,可能需要手动指定库路径。</think>### OpenCV链接错误解决方案 #### 一、问题分析 出现`libopencv_stitching.so.4.5.4d 文件格式未被识别`的错误,通常由以下原因导致: 1. **OpenCV版本不匹配**:编译时链接的OpenCV版本与系统实际安装的版本冲突,可能安装了多版本OpenCV导致路径混淆[^2][^4]。 2. **架构兼容性问题**:库文件可能为其他架构(如ARM)编译,无法在当前系统(如x86_64)使用[^3]。 3. **编译配置错误**:CMake未正确配置OpenCV路径或依赖项[^1][^5]。 --- #### 二、解决步骤 ##### 1. 确认OpenCV安装版本 通过终端执行以下命令验证已安装的OpenCV版本: ```bash pkg-config --modversion opencv4 ``` * 若输出非4.5.4,需修正环境变量`PKG_CONFIG_PATH`[^4]: ```bash export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH ``` ##### 2. 检查CMakeLists.txt配置 在项目的CMakeLists.txt中确保以下内容正确: ```cmake find_package(OpenCV REQUIRED) include_directories(${OpenCV_INCLUDE_DIRS}) target_link_libraries(你的项目名称 ${OpenCV_LIBS}) ``` * 若存在多个OpenCV版本,需强制指定路径: ```cmake set(OpenCV_DIR "/usr/local/share/opencv4") ``` ##### 3. 清理并重建项目 删除旧构建文件并重新配置: ```bash rm -rf build/ mkdir build && cd build cmake .. -DCMAKE_PREFIX_PATH=/usr/local make ``` ##### 4. 验证库文件格式 检查`libopencv_stitching.so`的架构是否匹配当前系统: ```bash file /usr/lib/x86_64-linux-gnu/libopencv_stitching.so.4.5.4d ``` * 若输出包含`ELF 64-bit LSB shared object, x86-64`则为正常,若显示`ARM`等则需重新编译OpenCV[^3]。 ##### 5. 重新编译安装OpenCV 若库文件损坏或架构错误: ```bash cd opencv-4.5.4/build cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. make -j$(nproc) sudo make install sudo ldconfig ``` --- #### 三、关键注意事项 1. **多版本隔离**:使用虚拟环境或`Docker`隔离不同OpenCV版本环境[^2]。 2. **依赖完整性**:安装OpenCV时需包含`stitching`模块: ```bash cmake -DBUILD_opencv_stitching=ON .. ``` 3. **符号链接修复**: ```bash sudo ln -sf /usr/local/lib/libopencv_stitching.so.4.5 /usr/lib/x86_64-linux-gnu/ ``` ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值