本题的想法很简单,就是模拟手算乘法。不一样的是,需要控制输出的结果:每一位都是由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. EXCEL datatable 根据列名自动写入到相应属性、字段或列中

    string path = openFileDialog1.FileName; try { DataTable dt = ExcelHelper.ExcelInput(path); ; ; ; ; i ...

  2. MapReduce格式与类型

    MapReduce Types MapReduce是一个简单的数据处理模型,map与reduce的输入和输出类型都为key-value形式的键值对. map: (K1, V1) → list(K2, ...

  3. css学习笔记(4)

    让顶部导航固定于页面的最顶端,无论页面上下滚动,顶部导航始终处在最顶端. *{ margin:0; padding:0}body{ padding-top:60px; }#nav{ width:100 ...

  4. 一、Owin Identity的使用

    参照http://www.cnblogs.com/r01cn/p/5177708.html教程. 注意点: 1.Nuget包分别下载Microsoft.AspNet.Identity(Owin必须), ...

  5. ubuntu 下rar解压工具安装方法

    1.压缩功能安装 sudo apt-get install rar卸载 sudo apt-get remove rar2.解压功能安装 sudo apt-get install unrar卸载 sud ...

  6. IDEA中PlantUML的使用

    PlantUML官网地址:http://www.plantuml.com/ IDEA中安装PlantUML Plugins File-->Settings-->Plugins-->I ...

  7. Jmeter学习一:Jmeter性能测试环境搭建(Windows下)

    最近刚开始接触Jmeter性能测试,现总结环境搭建如下: 一.windows安装JDK步骤与环境变量配置: 1.先将下载的JDK安装到其默认目录:C:\Program Files\Java\jdk1. ...

  8. js实现图片的淡入淡出

    思想: 其实是运动的一种,就是当鼠标移入div中时,将div的透明度变大, 当鼠标移动出来的时候透明度变回原来. 你可以尝试写一下,不会再看看代码 <style> #div1{ width ...

  9. memcache c++使用

    memcache作为一个内存数据库,快速查询的功能. 在c++下面使用memcache需要一个memcache client.c++版本的是libmemcached http://libmemcach ...

  10. Android IOS WebRTC 音视频开发总结(七三)-- 我为什么走上了创业这条不归路?

    本文主要介绍自己为什么选择创业,文章最早发表在我们的微信公众号上,支持原创,详见这里, 欢迎关注微信公众号blackerteam,更多详见www.rtc.help 2016.06.01对公司来说是个很 ...