模拟试——match
来源:互联网 发布:网易养猪场知乎 编辑:程序博客网 时间:2024/06/03 11:17
题目大意:
以上是每个数需要的火柴数。
火柴分为A,B,C三堆,然后用光各拼出一个数,分别是a,b,c,这三个数都不能有前导0(0本身除外),再选择一个运算符op(+,-,*,/,其中/是整数除),使得a op b = c。因为小明只学过0到999的数,所以只能拼0到999这1000个数。
求最后能拼出多少种这样的等式。
对于所有的数据,2 ≤ A,B,C ≤ 21
题解:
搜索,把3种火柴能摆的所有情况全部暴力搜出来,因为最高只能拼成3位数即0~999可以拼,所以我们搜到4位数就exit。
最后强行枚举。
PS:不能除0.
const num:array [0..9] of longint=(6,2,5,5,4,5,6,3,7,6);var cd:array [1..3,0..999] of boolean; i,j,a,b,c,ans:longint;procedure dfs(k,ks,now,g:longint);var i:longint;begin if now>999 then exit; if ks=g then begin cd[k,now]:=true; exit; end; if (now<>0) or (num[0]=g) then dfs(k,ks+num[0],now*10,g); for i:=1 to 9 do if ks+num[i]<=g then dfs(k,ks+num[i],now*10+i,g);end;function check(l,r:longint):longint;begin check:=0; if l-r>=0 then if cd[3,l-r] then inc(check); if l+r<=999 then if cd[3,l+r] then inc(check); if l*r<=999 then if cd[3,l*r] then inc(check); if r<>0 then if cd[3,l div r] then inc(check);end;begin assign(input,'match.in'); reset(input); assign(output,'match.out');rewrite(output); readln(a,b,c); dfs(1,0,0,a); dfs(2,0,0,b); dfs(3,0,0,c); ans:=0; for i:=0 to 999 do if cd[1,i] then for j:=0 to 999 do if cd[2,j] then ans:=ans+check(i,j); writeln(ans); close(input); close(output);end.
阅读全文
1 0
- 模拟试——match
- ZOJ 2524- Football Match (模拟+map)
- 3472. 【NOIP2013模拟联考8】匹配(match)
- [jzoj3472]【NOIP2013模拟联考8】匹配(match)
- zoj1642——Match for Bonus
- BZOJ1264——[AHOI2006]基因匹配Match
- scala 学习(十八)——match
- match
- match
- match
- $match
- 正则表达式之匹配——match()方法
- Codeforces Round #244 (Div. 2)——Match & Catch
- JavaScript String对象方法——search(),match(),replace(),split()
- match与index——vlookup的加强版
- Elasticsearch2.x 全文检索之——Match Query
- hdu5917——Wrestling Match(二分图染色)
- Leetcode挑战题——Repeated String Match
- SpringBoot init
- IOS响应式编程框架ReactiveCocoa(RAC)使用示例
- 数据挖掘系列(2)--关联规则FpGrowth算法
- U盘exe病毒还原文件以及永久防毒
- 可自动换行的RadioGroup
- 模拟试——match
- JS移动某些元素到指定位置
- Kotlin Coroutine 协程Gradle配置
- MAC下GDB出现问题-Unable to find Mach task port for process-id 1262: (os/kern) failure (0x5).
- Android常用组件-editview
- JAVA---TTML
- docker搭建registry(对于认证的个人用户)
- Kendo Grid 指定位置增加记录
- Ecshop后台增加|添加商店设置选项和使用方法详解