题意:给你两个数p和x,然后让你找出一个长度为p的数,把它的最后移到最前面之后得到的数是原来数字的x倍,有很多这样的数取最小。

思路:枚举最后一位,然后就可以推出整个的一个数,然后比较得到的数的第一个数字和枚举的数字是否相等既可以。

 #include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std; int p,x;
char str[]; int main()
{
scanf("%d%d",&p,&x);
bool flag=false;
for(int i=; i<=; i++)
{
int m=i;
int c=;
int y=i;
str[]=m+'';
for(int j=; j<=p; j++)
{
int cc=(y*x+c)/;
y=(y*x+c)%;
str[j]=y+'';
c=cc;
}
if(y==m&&str[p-]!=''&&c==)
{
flag=true;
for(int k=p-; k>=; k--)
{
printf("%c",str[k]);
}
printf("\n");
break;
}
}
if(!flag) printf("Impossible\n");
return ;
}

cf B Very Beautiful Number的更多相关文章

  1. Codeforces 55D Beautiful Number

    Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisibl ...

  2. zoj Beautiful Number(打表)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829 题目描述: Mike is very lucky, as ...

  3. beautiful number 数位DP codeforces 55D

    题目链接: http://codeforces.com/problemset/problem/55/D 数位DP 题目描述: 一个数能被它每位上的数字整除(0除外),那么它就是beautiful nu ...

  4. zoj 2829 Beautiful Number

    Beautiful Number Time Limit: 2 Seconds      Memory Limit: 65536 KB Mike is very lucky, as he has two ...

  5. hdu 5179 beautiful number

    beautiful number 问题描述 令 A = \sum_{i=1}^{n}a_i * {10}^{n-i}(1\leq a_i \leq 9)A=∑​i=1​n​​a​i​​∗10​n−i​ ...

  6. Beautiful Number

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829 Beautiful Number Time Limit: 2 Sec ...

  7. HDU 5179 beautiful number (数位dp / 暴力打表 / dfs)

    beautiful number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  8. Codeforces 55D Beautiful Number (数位统计)

    把数位dp写成记忆化搜索的形式,方法很赞,代码量少了很多. 下面为转载内容:  a positive integer number is beautiful if and only if it is  ...

  9. CF#231DIV2:A Good Number

    Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a numbe ...

随机推荐

  1. python的私有变量解析

    在内的内部定义并使用,外部无法訪问,以双下划线作为前作,定义后被python转为 _classname__变量名了 ------------------------------------------ ...

  2. android ScrollView 充满屏幕

    android:fillViewport=true ScrollView下面的组件如果有android:layout_height="fill_parent"或android:la ...

  3. ExtJs4学习(四):Extjs 中id与itemId的差别

       为了方便表示或是指定一个组件的名称,我们一般会使用id或者itemId进行标识命名. (推荐尽量使用itemId.这样能够降低页面唯一标识而产生的冲突) id:   id是作为整个页面的Comp ...

  4. 通过MultipleOutputs写到多个文件

    MultipleOutputs 类可以将数据写到多个文件,这些文件的名称源于输出的键和值或者任意字符串.这允许每个 reducer(或者只有 map 作业的 mapper)创建多个文件. 采用name ...

  5. c#中跨线程调用windows窗体控件

    c#中跨线程调用windows窗体控件解决. 我们在做winform应用的时候,大部分情况下都会碰到使用多线程控制界面上控件信息的问题.然而我们并不能用传统方法来做这个问题,下面我将详细的介绍.首先来 ...

  6. Java序列化之Serializable

    Java的序列化流程如下: Java的反序列化流程如下: 注意:并不是所有类都需要进行序列化,主要原因有两个 1)安全问题.Java中有的类属于敏感类,此类的对象数据不便对外公开,而序列化的对象数据很 ...

  7. wpf提示背景,资源样式

    查找资源时多用element.TryFindResource() <TextBox FontSize="17" Height="26" Margin=&q ...

  8. [转] EF Configuring a DbContext

    本文转自:https://docs.microsoft.com/en-us/ef/core/miscellaneous/configuring-dbcontext Note This document ...

  9. asp.net 的脚本

    asp.net的 Web 控件有时会包装一些用户端脚本 (client-side scripting),在控件被绘制时输出到用户端,这些脚本多数被包装在 DLL 的资源档中,并由 ScriptReso ...

  10. SQL常用的语句和函数

    order by 的数值型灵活使用 select * from table_a where order by decode(函数,'asc',1,'desc',-1)*jsny; 控制试图的访问时间: ...