usaco Prime Cryptarithm
来源:互联网 发布:mac 思维导图 编辑:程序博客网 时间:2024/06/06 04:35
小暴力,题意有点坑,看了别人的才完全明白。
题意:给你n个数。判断n个数能够形成多少种成立的算式。算式成立的标准是,*号必须由n个数代替。当然还有最坑的The partial products must be three digits long, even though the general case (see below) might have four digit partial products. 计算过程中间数必须是3位。
/**TASK: crypt1LANG: C++ID: DickensTone**/#include<cstdio>#include<cstring>#include<fstream>int num;bool no(int x){ //printf("%d %d\n", x, num); //printf("-------------\n"); while(x) { int t = x % 10; //printf("%d\n", t); if(!(num & (1 << t))) return true; x = x / 10; } return false;}int main(){ freopen("crypt1.in", "r", stdin); freopen("crypt1.out", "w", stdout); int n; while(scanf("%d", &n) == 1) { num = 0; int cnt = 0; for(int i = 0; i < n; i++) { int t; scanf("%d", &t); //printf("%d\n", num); num = num | (1 << t); } //printf("%d\n", num); for(int i = 101; i < 1000; i++) { if(no(i)) continue; for(int j = 11; j < 100 && i * j <= 9999; j++) { if(no(j)) continue; bool ok = true; int t2 = (j % 10) * i, t1 = (j / 10) * i; if(t1 >= 1000 || t2 >= 1000) continue; int t = t1 * 10 + t2; if(no(t1) || no(t2) || no(t)) ok = false; if(ok) { cnt++; //printf("%d %d\n", t1, t2); } } } printf("%d\n", cnt); } return 0;}
阅读全文
0 0
- 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
- USACO Prime Cryptarithm
- 分享大牛们的刷题经验——比你聪明的人还在拼命努力,你有什么资格浪费时间
- 太上感应篇0025
- 【斜率优化DP】BZOJ1911 [Apio2010]特别行动队
- Kali Linux 2017.2一个小bug
- htop
- usaco Prime Cryptarithm
- hashmap和hashtable区别
- 三极管相关知识点释疑(一)
- 二、书写Makefile的规则
- 机房模拟赛 2017年9月27日
- 瀑布式开发和敏捷开发区别
- maogodb 安装在linux中
- 人工智能绪论
- 常用手机屏幕尺寸大小