USACO之Prime Cryptarithm
来源:互联网 发布:ps是什么软件 编辑:程序博客网 时间:2024/06/06 02:18
刚开始我对这道题有误解想着要用到所有的整数,原来不需要,只是用到它所提供的数就行了。没有动dfs。
/* ID:m1519591 PROG: crypt1 LANG:C++*/#include<iostream>#include<fstream>using namespace std;//ifstream cin("crypt1.in");//ofstream cout("crypt1.out");int hash[10]={0};bool check(int n){ int flag=0; while(n) { if(!hash[n%10]) return false; n/=10; } return true;}int main(){ int n,x,count=0; int mil1=0,mil2=0,sum=0; cin>>n; for(int i=0;i<=n-1;i++) { cin>>x; hash[x]=1; } for(int i=100;i<=999;i++) { if(!check(i)) continue; for(int j=10;j<=99;j++) { if(!check(j)) continue; sum=i*j; if(sum<1000||sum>9999) continue; if(!check(sum)) continue; mil1=i*(j%10); if(mil1<100||mil1>999) continue; if(!check(mil1)) continue; mil2=i*(j/10); if(mil2<100||mil2>999) continue; if(!check(mil2)) continue; count++; } } cout<<count<<endl; return 0;}
阅读全文
0 0
- USACO之Prime Cryptarithm
- USACO Prime Cryptarithm Accepted
- Prime Cryptarithm(USACO)
- USACO 1.3-Prime Cryptarithm
- [USACO] Prime Cryptarithm
- USACO 1.3 Prime Cryptarithm
- USACO Prime Cryptarithm
- usaco Prime Cryptarithm
- [USACO]Prime Cryptarithm
- USACO Prime Cryptarithm 杂水题
- USACO:Prime Cryptarithm
- usaco 1.3 Prime Cryptarithm
- USACO Prime Cryptarithm
- USACO-Prime Cryptarithm
- USACO Prime Cryptarithm
- USACO Prime Cryptarithm
- usaco Prime Cryptarithm (暴力)
- USACO 1.3 Prime Cryptarithm
- Apache 服务器下载及安装
- 极光推送集成步骤及注意事项
- android sqlite 一次创建多个表
- C/C++UDP套接字之一般流程
- 91-95.c个人练习。
- USACO之Prime Cryptarithm
- Vue jquery.masonry 滑动自动加载 瀑布流
- C#文本框的KeyPress事件对键盘输入进行限制
- 主元素I
- 23.6 23.7 Web environment Web环境变量读取
- JavaMail笔记
- 通过NFS方式进行源码级别的共享进行多台机器间的部署。
- Initialization error Could not load "D:\install\PLSQL\instantclient_11_2\oci
- 用递归方法解析XML