uva 10344 23 Out of 5

海康VisionMaster图形定位实战:十字形Mark点精准匹配技巧 本文深入解析了海康VisionMaster图形定位模块在工业自动化中实现十字形Mark点精准匹配的实战技巧。文章从ROI设置、核心参数调优(如定位方式、尺度模式、对比度阈值)到工业场景应用与避坑指南,系统性地分享了提升匹配成功率和稳定性的关键步骤,帮助工程师应对复杂现场环境,实现高效、可靠的视觉定位。 阅读详情

题目地址:

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

题目描述:

Problem I

23 Out of 5

Input: standard input

Output: standard output

Time Limit: 1 second

Memory Limit: 32 MB

Your task is to write a program that can decide whether you can find an arithmetic expression consisting of five given numbers (1<=i<=5) that will yield the value 23.
For this problem we will only consider arithmetic expressions of the following from:

 
where : {1,2,3,4,5} -> {1,2,3,4,5} is a bijective function
and  {+,-,*} (1<=i<=4)

Input

The Input consists of 5-Tupels of positive Integers, each between 1 and 50.
Input is terminated by a line containing five zero's. This line should not be processed.

Output

For each 5-Tupel print "Possible" (without quotes) if their exists an arithmetic expression (as described above) that yields 23. Otherwise print "Impossible".

Sample Input

1 1 1 1 1
1 2 3 4 5
2 3 5 7 11
0 0 0 0 0

Sample Output

Impossible
Possible
Possible


题意:添加符号和数字 使等式成立。

题解:暴力搜索

代码:

/*
23 Out of 5 uva 10344

please read the problem clearly, 
 PI {1,2,3,4,5} -> {1,2,3,4,5} is a bijective function
 
 
 we also should be familiar with the non-recursive structure,the Kye is the backtrack's value and status should rollback



 if you want the all permutation int the next_permutation() you must set the array[] int the first sort in the start
*/
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string>
#include<algorithm>
using namespace std;

int A[5+5]={0};
int signal=0;//0->+ 1->- 2->*

/*caculate the number*/
int Calc(int a,int b,int c)
{
    int Sum=0;
    switch(c)
    {
    case 0:
        Sum=a+b;
        break;
    case 1:
        Sum=a-b;
        break;
    default:
        Sum=a*b;
        break;
    }
    return(Sum);
}

/*code blocks*/
int Blocks(int A[])
{
    int a0=0,a1=0,a2=0,a3=0;
    int Sum=0;
    for(a0=0;a0<=2;a0++)
    {
        Sum=Calc(A[0],A[1],a0);//Sum should rollback the value before the Calc,this is not recursive,we should make a obvious rollback operation
        for(a1=0;a1<=2;a1++)
        {
            int Tmp1=Sum;
            Sum=Calc(Tmp1,A[2],a1);
            for(a2=0;a2<=2;a2++)
            {
                int Tmp2=Sum;
                Sum=Calc(Tmp2,A[3],a2);
                for(a3=0;a3<=2;a3++)
                {
                    int Tmp3=Sum;
                    Sum=Calc(Tmp3,A[4],a3);
                    //printf("***%d***\n",Sum);
                    if(Sum==23)
                    {
                        return(1);//possible
                    }
                    Sum=Tmp3;
                }
                Sum=Tmp2;
            }
            Sum=Tmp1;
        }
    }
    return(0);
}

/*code block*/
int Blocks1()
{
    int flag=0;
    int B[5]={0};
    int i0,i1,i2,i3,i4;
    for(i0=0;i0<=5-1;i0++)
    {
        B[0]=A[i0];
        for(i1=0;i1<=5-1;i1++)
        {
            B[1]=A[i1];
            for(i2=0;i2<=5-1;i2++)
            {
                B[2]=A[i2];
                for(i3=0;i3<=5-1;i3++)
                {
                    B[3]=A[i3];
                    for(i4=0;i4<=5-1;i4++)
                    {
                        B[4]=A[i4];
                        //caculate the expression
                        {
                            flag=Blocks(B);
                            if(flag)
                            {
                                return(1);
                            }
                        }
                    }
                }
            }
        }
    }
    return(0);
}

/*for test*/
int test()
{
    return(0);
}

/*main process*/
int MainProc()
{
    while(scanf("%d%d%d%d%d",&A[0],&A[1],&A[2],&A[3],&A[4])!=EOF&&(A[0]+A[1]+A[2]+A[3]+A[4])>0)
    {
        sort(A,A+5);
        int flag=0;
        //flag=Blocks1();
        do
        {
            if(A[0]==2&&A[1]==3)//why not have this path in the permutation
            {
                A[0]=2;
            }
            flag=Blocks(A);
            if(flag)
            {
                break;
            }
        }while(next_permutation(A,A+5));
        if(!flag)
        {
            printf("Impossible\n");
        }
        else
        {
            printf("Possible\n");
        }
    }
    return(0);
}

int main()
{
    MainProc();
    return(0);
}






Tesseract in Java - Intellij IDEA对Tess4J的配置和使用 最近要弄OCR,搜到这个,官网全英文,很烦,看看有没有中文的博客介绍,擦,一个比一个奇葩,还是自己按照官方的来吧,外网慢的很,传到csdn给大家下载。中文训练库下载地址: http://download.csdn.net/detail/d_dmelon/9916532Tess4J3.4下载地址: http://download.csdn.net/detail/d_dmelon/9916519安装 阅读详情

相关推荐

【头歌实训:逆置顺序表】

根据提示,在右侧编辑器补充函数rev的代码,使用顺序表L的空间就地逆置L。},要求时间复杂度为O(n),空间复杂度为O(1)。第一行为顺序表逆置之前的元素。每个数据后一个空格。第二行为顺序表逆置之后的元素。每个数据后一个空格。本关任务:设计一个算法,将一个顺序表L的元素{a。第一行为顺序表中元素个数n。第二行为空格隔开的n个整数。开始你的任务吧,祝你成功!

guang_Lee的博客 1004

UVaOJ10344 - 23 out of 5

10344 - 23 out of 5 Time limit: 3.000 seconds Your task is to write a program that can decide whether you can find an arithmetic expression consisting of five given numbers (1<=i<=5) that will y

c随遇er安的专栏 658

别再让OCV拖慢你的芯片!手把手教你用set_timing_derate优化STA时序(附CPPR实战)

本文深入探讨了芯片设计中OCV(On-Chip Variation)对时序分析的影响,并提供了使用`set_timing_derate`优化STA时序的实战指南。通过分阶段derate设置和CPPR技术,有效减少时序违例,提升芯片性能。文章结合TSMC 7nm工艺案例,详细解析了OCV建模与优化策略,助力工程师实现时序收敛。

weixin_42525005的博客 307

uva 10344 - 23 out of 5

点击打开链接 题目意思:给定5个数,还有三种运算符 * + - ,问我们是否能够由这些数和运算符最后的值为23。 解题思路:我们知道5个数的全排列为5!种,那么我们只要去枚举这个全排列中每一个排列进行搜索,是否有23点出现有的话标记ans为1,直接退出。(注意必须全排列的查找,不能只按输入的顺序) 代码: //计算5个数3个运算符能否组成23点 //我们知道5个数的全排列为...

编程资料大全 179

菜鸟-需求预测与分仓规划

通过修改模型的损失函数对问题进行求解,比其它单模型的效果好很多。

永不理解_fdu的博客 4888

基于ROS2的实时视频流转换:image2rtsp在多路相机采集中的应用

本文详细介绍了如何在ROS2机器人系统中使用image2rtsp工具,将ROS2内部的相机图像话题实时转换为标准的RTSP视频流。重点阐述了其安装配置、核心参数调优,并提供了多路相机采集的实战方案,解决了机器人视觉数据跨平台、跨网络分发的难题,极大提升了视频流集成的部署效率。

weixin_29214559的博客 401

uva 10344 23 out of 5(递归+全排列)

这道题好像不是回溯就是简单的递归,全排列一下就ok啦,晚上估计不能好好刷题了 代码: #include #include #include #include using namespace std; int cmp(const void *c,const void *d) { return *(int *)c - *(int *)d ; } int flag; int a[5]; void

勿忘初心 631

汽车电子电气架构演进:从分布式ECU到域集中与中央计算

汽车电子电气架构(EEA)是整车电子系统的顶层设计框架,定义了计算、通信、供电等核心要素的组织方式。其演进遵循从分布式到集中式的技术路径,旨在解决传统架构下ECU数量膨胀带来的成本、复杂度和协同难题。通过域控制器(DCU)整合功能域,以及向中央计算+区域控制架构发展,实现了硬件资源池化、软硬件解耦与高速通信。这一变革的核心技术价值在于提升算力利用率、简化线束布局、支持软件定义汽车(SDV)与持续OTA升级。在智能电动汽车时代,新架构为智能座舱、自动驾驶等复杂应用提供了可扩展的平台基础,推动了汽车产业从硬件导

weixin_30326741的博客 395

UVA 10344 - 23 out of 5

题目大意:输入五个数, 判断是否存在情况使得式子( ( a(1) o a(2) ) o a(3) ) o a(4) ) o4 a(5)等于23。五个数的任意排序,o为运算符‘+’,‘-’,或‘*’。 解题思路:运算符的顺序用三进制来表示,五个数的全排序用next_permutation来计算。 ac代码: #include #include #include using nam

99度灰的博客 323

Utrust4701F与Utrust2700R读写器在银河麒麟系统的安装及测试步骤说明

Utrust4701F与Utrust2700R读写器支持银河麒麟系统,广泛应用会员管理、支付管理等领域。本文将重点介绍Utrust4701F与Utrust2700R读写器在银河麒麟系统的安装及测试步骤说明。以上方法适用于主流国产操作系统,如 优麒麟(UbuntuKylin)/ 中标麒麟(NeoKylin) / UOS(统信操作系统)/ 中兴新支点 / 红旗 linux(redflag linux)/ 普华 Linux(I-soft OS) / 威科乐恩 Linux(WiOS)等

华翔天诚科技 1842

告别手动标注!用ENVI Classic高效搞定高光谱图像语义分割标签(以农业/地物分类为例)

本文详细介绍了如何利用ENVI Classic实现高光谱图像的半自动化智能标注,特别针对农业和地物分类场景。通过光谱特征分析、智能标注技巧和MAT文件转换,显著提升标注效率和质量,助力AI模型训练。

weixin_28694169的博客 254

UVa 10344 23 out of 5

/* 回溯法 最坏情况:5!*3^4 */ #include #include #include #include #include using namespace std; const int MAX = 5; const int OPTS = MAX-1; //操作符个数 int A[MAX]; int dfs(int cur, int sum) { if(cur == O

cugfjp的专栏 517

一套C#接口通吃安川/发那科/库卡:工业机器人统一控制框架设计与产线踩坑实录

我们把机器人的通用能力抽象为接口,涵盖连接、运动、IO、寄存器、状态、报警六大类能力,所有品牌适配器都必须实现这个接口。/// 工业机器人统一控制接口// 基础连接// 运动控制// IO与寄存器// 状态与报警// 事件工业机器人统一控制框架的本质,不是把所有品牌的功能都做平,而是找到通用能力的最大公约数,通过分层抽象把品牌差异隔离在底层。上层业务只关注工艺和流程,不需要关心机器人是什么品牌、用什么SDK、通信协议是什么。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 413

UVA10344 23 out of 5【暴力+DFS】

Your task is to write a program that can decide whether you can find an arithmetic expression consisting of five given numbers ai (1 ≤ i ≤ 5) that will yield the value 23.   For this problem we will ...

海岛Blog 737

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

UVa 10344 23 out of 5 (全排列枚举&回溯)

10344 - 23 out of 5 Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1285 Your task is to write a program t

AC,∑ndless 1184

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

uva 10344 23 out of 5(DFS)

23 Out of 5 Input: standard input Output: standard output Time Limit: 1 second Memory Limit: 32 MB Your task is to write a program that can decide whether you can find an arithmetic expression co

不慌不忙、不急不躁 1379

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

UVA 10344 23 out of 5

UVA-10344题意:求(((((a1 o a2) o a3)o a4 )o a5),其中o的选择范围{+,- ,*},a1-a5由给定的5个数中任意顺序。看能不能使得结果为23。 解题思路:先枚举a1-a5的顺序(STL 里的 next_permutation 简直强大),然后再枚举每个o选+-*中的哪一个。/******************************************

QzNarsh的博客 436

UVa 10344 - 23 out of 5

开始用的回溯TLE了,后来改用全排列+DFS  AC。 代码如下: (0.728s): #include #include #include #include #include #include using namespace std; int a[5], flag; void solve(int cur, int sum) { if(cur == 5) {

GooMaple 1450

UVa 10344 - 23 out of 5

回溯法的简单应用。 不过后来用别人的全排列的方法试了一下,竟然时间比回溯法少了

一只冰熊 800

UVA - 10344 23 out of 5

Problem I 23 Out of 5 Input: standard input Output: standard output Time Limit: 1 second Memory Limit: 32 MB Your task is to write a program that can decide whether you can find an arithmetic ex

七夜 903

UVA 10344 23 out of 5

UVA 10344 23 out of 5 找23点。。用深搜。。直到找到23点为止。。 每个数字有3种情况 + - * 找到5个数字就判断。。 #include using namespace std; #include #include int num[5]; int judge; void dfs(int star, int sum) { if

Remilia's 1109

uva10344 - 23 out of 5

就是枚举+ 全排列 一开始写复杂了,只要每次传进去写三次+-* 就行了 题目: Problem I 23 Out of 5 Input: standard input Output: standard output Time Limit: 1 second Memory Limit: 32 MB Your task is to write a program th...

aiezhen1717的博客 139

[回溯]23 out of 5 UVA 10344

回溯题目

九问的烦恼 1828

uva-10344 - 23 out of 5

Problem I 23 Out of 5 Input: standard input Output: standard output Time Limit: 1 second Memory Limit: 32 MB Your task is to write a program that can decide whether you can find an arithmetic ex

写东西的地方 606
上一篇: uva 301 Transportation
下一篇: uva 331 Mapping the Swaps
hackerwin7
博客等级 码龄14年 115粉丝 144原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值