博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
A very hard Aoshu problem
阅读量:5863 次
发布时间:2019-06-19

本文共 1655 字,大约阅读时间需要 5 分钟。

A very hard Aoshu proble

Problem Description
Aoshu is very popular among primary school students. It is mathematics, but much harder than ordinary mathematics for primary school students. Teacher Liu is an Aoshu teacher. He just comes out with a problem to test his students:
Given a serial of digits, you must put a '=' and none or some '+' between these digits and make an equation. Please find out how many equations you can get. For example, if the digits serial is "1212", you can get 2 equations, they are "12=12" and "1+2=1+2". Please note that the digits only include 1 to 9, and every '+' must have a digit on its left side and right side. For example, "+12=12", and "1++1=2" are illegal. Please note that "1+11=12" and "11+1=12" are different equations.
 

 

Input
There are several test cases. Each test case is a digit serial in a line. The length of a serial is at least 2 and no more than 15. The input ends with a line of "END".
 

 

Output
For each test case , output a integer in a line, indicating the number of equations you can get.
 

 

Sample Input
1212
12345666
1235
END
 

 

Sample Output
2
2
0
                                                                          
 
由于n小于=15,故暴力枚举即可。又由于只有数字1~9组成,无需考虑几个相邻的0的情况。很简单的一道水题,我们用二进制来枚举。水过。
 
 
 
 
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 using namespace std; 8 char str[30]; 9 int get(int i,int j,int x,int cnt)10 {11 int ret,a,b,c;12 int s=i;13 ret=a=0;14 for(a=0;a

 

 
 
 
 
 
 
 
 
 
 
 

转载于:https://www.cnblogs.com/767355675hutaishi/p/4115686.html

你可能感兴趣的文章
Android TabActivity使用方法
查看>>
java ShutdownHook介绍与使用
查看>>
Eclipse的 window-->preferences里面没有Android选项
查看>>
《麦田里的守望者》--[美]杰罗姆·大卫·塞林格
查看>>
[置顶] 深入探析Java线程锁机制
查看>>
遇到的那些坑
查看>>
央行下属的上海资信网络金融征信系统(NFCS)签约机构数量突破800家
查看>>
[转] Lazy evaluation
查看>>
常用查找算法总结
查看>>
grep 零宽断言
查看>>
被神话的大数据——从大数据(big data)到深度数据(deep data)思维转变
查看>>
修改校准申请遇到的问题
查看>>
【DL-CV】浅谈GoogLeNet(咕咕net)
查看>>
python大佬养成计划----win下对数据库的操作
查看>>
Mysql 中创建索引和索引的使用问题
查看>>
(cons '(〇 . 前言) 《为自己写本-Guile-书》)
查看>>
监控软件zabbix之安装
查看>>
No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=arm64, VALID_ARCHS=armv7 armv7s)
查看>>
Exchange Server 2016 独立部署/共存部署 (七)—— DAG功能测试
查看>>
Linq==数据访问层?
查看>>