Codeforces 394 B. Very Beautiful Number
来源:互联网 发布:sugarnms网络管理下载 编辑:程序博客网 时间:2024/05/16 23:54
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int nb[1100000],p,x,ans[1100000];void ck(int* nb){ for(int i=1;i<=p;i++) { if(ans[i]>nb[i]) { for(int j=1;j<=p;j++) { ans[j]=nb[j]; } return ; } }}int main(){ scanf("%d%d",&p,&x); bool flag=false;for(int j=9;j>=1;j--){ memset(nb,0,sizeof(nb)); nb[p]=j; int res=0; for(int i=p-1;i>=0;i--) { int tk=(nb[i+1]*x+res); nb[i]=tk%10; res=tk/10; } if(nb[1]==0) continue; else if(nb[0]==j&&res==0) { if(flag==false) { memcpy(ans,nb,sizeof(ans)); flag=true; } ck(nb); }}if(flag==true){ for(int i=1;i<=p;i++) printf("%d",ans[i]); putchar(10); return 0;} puts("Impossible"); return 0;}
0 0
- Codeforces 394 B. Very Beautiful Number
- codeforces 394B Very Beautiful Number
- Codeforces 394B Very Beautiful Number(水题)
- code forces 394B Very Beautiful Number
- CF-394B Very Beautiful Number
- CF 394B:Very Beautiful Number
- Codeforces Round #231 (Div. 2)B. Very Beautiful Number
- Codeforces Round #231 (Div. 2) B. Very Beautiful Number
- Codeforces Round #231 (Div. 2) B Very Beautiful Number
- CF---B. Very Beautiful Number
- codeforces 394 B. Very Beautiful Number(思路较难,优化的地方多)好题。。。
- CF:394B - Very Beautiful Number(逆推)
- CF 394B Very Beautiful Number(逆推)
- CF 231div2 B. Very Beautiful Number
- Codeforces Round #231 (Div. 2) B Very Beautiful Number(数字递推)
- codeforces#231_div2_B Very Beautiful Number 高精度枚举
- B. Very Beautiful Number codeference 非常考验数学思维的一个问题
- codeforces--651B Beautiful Paintings
- ogre渲染优化
- Codeforces Round #231 (Div. 2)A. Counting Sticks
- poj - 1177 - Picture(离线化+扫描线+线段树)
- Codeforces Round #231 (Div. 2)B. Very Beautiful Number
- Linux 下制作虚拟软盘镜像
- Codeforces 394 B. Very Beautiful Number
- 分治法 Divide and Conquer - Closest Pair of Points 找最近点对
- BabyLinux制作过程详解
- CF Round231C (ZWJ 神构造)
- codeforces round231 DIV2
- 整个进程安全CoInitializeSecurity
- .net实现加密算法小结
- 黑马程序员技术博客之copy小程序
- 黑马程序员技术博客之堆排序