USACO-Section1.3 Prime Cryptarithm
2017-06-02 22:35
369 查看
Prime Cryptarithm
2017.06.01题解
先搜索出乘数和被乘数的所有情况,再检验所得的积是否满足条件即可。代码
/* ID: xhzdcyy1 PROB: barn1 LANG: C++ */ #include <iostream> #include <fstream> #include <string> #include <algorithm> #define cin fin #define cout fout using namespace std; ofstream fout ("barn1.out"); ifstream fin ("barn1.in"); bool arr[200]={false}; int inter[200]; bool cmp(int a,int b){ return a-b>0; } int main() { int m,s,c; cin>>m>>s>>c; int min=200,max=0; for(int i=0;i<c;i++){ int tmp; cin>>tmp; if (tmp>max) max=tmp; if (tmp<min) min=tmp; arr[tmp]=true; } int tmp1=0,cc=0; for(int i=min+1;i<=max;i++){ if(!arr[i]){ ++tmp1; } else{ if(tmp1){ inter[cc++]=tmp1; tmp1=0; } } } sort(inter,inter+cc,cmp); int res=max-min+1; for(int i=0;i<m-1;i++){ res-=inter[i]; } cout<<res<<endl; return 0; }
相关文章推荐
- USACO-Section 1.3 Prime Cryptarithm[...]
- USACO-Section1.3 Prime Cryptarithm
- USACO Section 1.3 Prime Cryptarithm
- USACO Section 1.3 Prime Cryptarithm
- USACO-Section 1.3 Prime Cryptarithm(枚举)
- USACO - Chapter1 Section 1.3 - Prime Cryptarithm
- USACO Section 1.3: Prime Cryptarithm
- USACO: Section 1.3 -- PROB Prime Cryptarithm
- USACO Section 1.3 : Prime Cryptarithm
- [USACO]Section 1.3 Prime Cryptarithm
- USACO Section1.3 Prime Cryptarithm 解题报告
- [USACO1.3]牛式 Prime Cryptarithm
- USACO 1.3 Prime Cryptarithm
- USCAO section1.3 Prime Cryptarithm(感觉思路挺好)
- USCAO section1.3 Prime Cryptarithm(感觉思路挺好)
- USACO section 1.3.4 Prime Cryptarithm
- USACO 1.3 Prime Cryptarithm
- usaco 1.3 Prime Cryptarithm
- P1211 [USACO1.3]牛式 Prime Cryptarithm
- USACO 1.3 Prime Cryptarithm