自己的usaco代码---PROB Prime Cryptarithm
来源:互联网 发布:三星充电器数据 编辑:程序博客网 时间:2024/05/18 03:02
原创代码
仅供参考
欢迎评论O(∩_∩)O~
/*ID: 输你自己的PROG: crypt1LANG: C++*//* *** **------- *** ***------- *****/ #include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <string>#include <cmath>using namespace std;int a[12],b[16],c[7];int n;bool find(int x){ for(int i=1;i<=n;i++) if(x==a[i]) return true; return false; }bool can(){ int k=0; if(c[3]==0||c[5]==0) return false; for(int i=1;i<=3;i++) { b[++k]+=c[i]*c[4]; if(b[k]>9) { b[k+1]+=b[k]/10; b[k]%=10; } if(!find(b[k])) return false; } if(b[++k]!=0) return false; for(int i=1;i<=3;i++) { b[++k]+=c[i]*c[5]; if(b[k]>9){ b[k+1]+=b[k]/10; b[k]%=10; } if(!find(b[k])) return false; } if(b[++k]!=0) return false; for(int i=2;i<=4;i++){ b[++k]+=b[i]+b[i+3]; if(b[k]>9){ b[k+1]+=b[k]/10; b[k]%=10; } if(!find(b[k])) return false; } if(b[++k]!=0) return false; return true;}int main(){freopen("crypt1.in","r",stdin);freopen("crypt1.out","w",stdout);cin>>n;for(int i=1;i<=n;i++) cin>>a[i];int ans=0;for(int q=1;q<=n;q++) for(int w=1;w<=n;w++) for(int e=1;e<=n;e++) for(int r=1;r<=n;r++) for(int t=1;t<=n;t++){ memset(b,0,sizeof(b)); c[1]=a[q],c[2]=a[w],c[3]=a[e],c[4]=a[r],c[5]=a[t]; if(can()) ans++; }cout<<ans<<endl;return 0;}ps:
两个字
暴搜
- 自己的usaco代码---PROB Prime Cryptarithm
- 自己的usaco代码---PROB Broken Necklace
- 自己的usaco代码---PROB Milking Cows
- 自己的usaco代码---PROB Transformations
- 自己的usaco代码---PROB Palindromic Squares
- 自己的usaco代码---PROB Dual Palindromes
- 自己的usaco代码---PROB Mixing Milk
- 自己的usaco代码---PROB Barn Repair
- 自己的usaco代码---PROB Calf Flac
- 自己的usaco代码---PROB Greedy Gift Givers
- 自己的usaco代码---PROB Friday the Thirteenth
- 自己的usaco代码---PROB Name That Number
- USACO Prime Cryptarithm Accepted
- Prime Cryptarithm(USACO)
- USACO 1.3-Prime Cryptarithm
- [USACO] Prime Cryptarithm
- USACO 1.3 Prime Cryptarithm
- USACO Prime Cryptarithm
- ZOJ 3551 Bloodsucker
- 数据库范式——通俗易懂
- 源文件夹已是 NetBeans 项目文件夹 (可能仅在内存中)。
- linux 桌面开发
- 《Java程序代理器》- java桌面程序运行的前端启动框架
- 自己的usaco代码---PROB Prime Cryptarithm
- rpc通信
- 黑马程序员-Java面向对象-day10
- 二叉树的非递归遍历C实现
- vi eclipse插件 viPlugin的安装和破解方法
- <Win32_14>__win32控件(2)__教你自学掌握所有控件的玩法
- 8 个必备的PHP功能开发
- 安卓开发28:自定义View类
- 机器翻译重要过程(1)---数据预处理