NOIP2008 火柴棒等式
2015-09-19 16:38
393 查看
题目:http://www.luogu.org/problem/show?pid=1149#
分析:
不知道怎么做= -,于是暴力枚举,发现n^2最大只能1000,于是就设这个边界,于是就过了= -
代码:
分析:
不知道怎么做= -,于是暴力枚举,发现n^2最大只能1000,于是就设这个边界,于是就过了= -
代码:
#include <cstdio> #include <algorithm> using namespace std; const int p[15]={6,2,5,5,4,5,6,3,7,6}; const long long int inf=1000; int n,ans; void work() { long long int i,j; int sum,tmp; n-=4; for(i=0;i<=inf;i++) { for(j=0;j<=inf;j++) { sum=0; tmp=i; if(i==0) sum+=p[0]; else while(tmp>0) { sum+=p[tmp%10]; tmp/=10; } tmp=j; if(j==0) sum+=p[0]; else while(tmp>0) { sum+=p[tmp%10]; tmp/=10; } tmp=i+j; if(tmp==0) sum+=p[0]; else while(tmp>0) { sum+=p[tmp%10]; tmp/=10; } if(sum==n) ans++; } } printf("%d",ans); return; } int main() { scanf("%d",&n); work(); return 0; }
相关文章推荐
- StringHelper
- Apache CXF实战之二 传输pojo对象
- 函数回调例程
- execute、executeQuery和executeUpdate之间的区别
- 使用FIO测试磁盘iops
- 默认参数使用技巧
- featuretype
- 深藏不漏的注释/**/ 和 //
- 大道至简第一章读后感
- 基于kickstart定制自动化安装的linux镜像系统
- Unity UGUI 学习(一)——关于Canvas
- MTK手机启动流程
- #define和typedef
- 笔试题输入一串字符,倒叙单词输出,结尾符号不变
- VALIDATION PROBLEMS WERE FOUND problem:错误
- Android ViewFlipper 使用
- Android 记住密码和自动登录界面的实现(SharedPreferences 的用法)
- 洛谷P1739 表达式括号匹配解题报告
- php 出现 500 Internal Server Error错误问题解决
- IOS AppDelegate设置Root页面