本题的想法很简单,就是模拟手算乘法。不一样的是,需要控制输出的结果:每一位都是由1构成的整数。

代码如下:

 #include <iostream>
using namespace std; int a[][] ={{,,,},{,,,},{,,,},{,,,},{,,,},{,,,},{,,,},{,,,},{,,,},{,,,}}; int get(int n)
{
int k = ,mm,t;
if(n% == ) t = ;
if(n% == ) t = ;
if(n% == ) t = ;
if(n% == ) t = ; int nm = n*a[nm%][t]; while(nm!=)
{
mm = nm%;
if(mm == ) { nm = nm/; k ++;}
else nm = nm + n*a[mm][t];
}
return k;
} int main()
{
int n;
while(cin>>n)
cout<<get(n)<<endl;
return ;
}

注意二维数组的构造方式:  使得每一次第20行代码执行之后的所得到的数的末位是1。数组中的第一维是上一次nm对10的余数,第二维与所输入的数的末位对应。

另外注意,数组a是可以改变的,也就是说,如果遇到有其他的要求的时候,数组a可以根据要求来改变。

poj 2551 Ones的更多相关文章

  1. POJ 2551

    #include<iostream> #include<stdio.h> #include<string> using namespace std; //int m ...

  2. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  3. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  4. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  5. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  6. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  7. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  8. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

  9. POJ 2752 Seek the Name, Seek the Fame [kmp]

    Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17898   Ac ...

随机推荐

  1. Python Mysql 篇

    Python 操作 Mysql 模块的安装 linux: yum install MySQL-python window: http://files.cnblogs.com/files/wupeiqi ...

  2. 【maven】之使用tomcat7-maven-plugin自动编译的问题

    今天遇到一个奇怪的问题,项目依赖关系如下, 在web端通过tomcat7插件debug模式启动项目的时候,dao层写的代码不能加载,还是原来的代码效果, 然后我在eclipse部署一个tomcat,将 ...

  3. [补充工程统计case]科技活动经费sql2014

    select bd_glorgbook.glorgbookcode,bd_glorgbook.glorgbookname, gl_detail.explanation, bd_accsubj.disp ...

  4. nodejs-express 报错View is not a constructor

    可能是express版本问题 view修改为views – app.set('views',__dirname + '/views');

  5. PyCharm、IntelliJ IDEA等jetbrains软件授权服务器

    Paste_Image.png 图上链接:http://idea.qinxi1992.cnhttp://blog.lanyus.com/archives/174.htmlhttp://www.idea ...

  6. springboot + swagger

    swagger用于定义API文档. 好处: 前后端分离开发 API文档非常明确 测试的时候不需要再使用URL输入浏览器的方式来访问Controller 传统的输入URL的测试方式对于post请求的传参 ...

  7. java io 输入输出流

    数据流分类: 流序列中的数据既可以是未经加工的原始二进制数据, 也可以是经一定编码处理后符合某种格式规定的特定数据. 因此Java中的流分为两种: 1) 字节流:数据流中最小的数据单元是字节 2) 字 ...

  8. 数据库 MySql

    MySql 一,概述 1,什么是数据库? 数据的仓库,如:在ATM的示例中我们创建了一个 db 目录,称其为数据库 二,下载安装 想要使用MySQL来存储并操作数据,则需要做几件事情: a. 安装My ...

  9. pow的小事不简单

    http://acm.hdu.edu.cn/showproblem.php?pid=5878 #include<stdio.h> #include<iostream> #inc ...

  10. Asp.net 怎样去除表单多行文本框滚动条

    <textarea style="overflow:hidden;border-width:0px;">永远没有滚动条</textarea><text ...