描述:

It was said that when testing the first computer designed by von Neumann, people gave the following problem to both the legendary professor and the new computer: If the 4th digit of 2^n is 7, what is the smallest n? The machine and von Neumann began computing at the same moment, and von Neumann gave the answer first. Now you are challenged with a similar but more complicated problem: If the K-th digit of M^n is 7, what is the smallest n?

输入:

Each case is given in a line with 2 numbers: K and M (< 1,000).

输出:

For each test case, please output in a line the smallest n.

You can assume:

The answer always exist. 
The answer is no more than 100.


样例输入:

3 2
4 2
4 3

样例输出:

15
21
11

题目大意:

给出k和m求出最小的n,使得m的n次方的第k位为7。


代码如下:

#include<stdio.h>
#include<string.h>
#define N 1005
int n;
int k,m;
int asd[1005];
void check(int q)
{while(asd[q]!=7)                         //判断第k位是否已经等于7 {for(int i=0;i<N;i++)               //利用数组来存入大数一位一位的处理          {asd[i]=asd[i]*m;}for(int i=0;i<N;i++)               {asd[i+1]=asd[i]/10+asd[i+1];   //不断地将低位的数字除以10后加到高位去  asd[i]=asd[i]%10;                }  n++;  }
}
int main()
{while(scanf("%d %d",&k,&m)!=EOF){memset(asd,0,sizeof(asd));n=0;asd[0]=1;check(k-1);printf("%d\n",n); }return 0;
}

Find 7 Faster Than John Von Neumann相关推荐

  1. 读《Jonathan von Neumann and EDVAC》

    读<Jonathan von Neumann and EDVAC> 读了一遍,只明白了个大概意思,没看懂作者要说什么,似乎是在讲历史.这篇文章的主要目的是介绍冯.诺依曼在EDVAC上的贡献 ...

  2. stored-program Computer/von Neumann Architecture 冯诺依曼体系结构

    0.Computer is an integration of hardwware and software. 计算机是硬件与软件的结合体 1.Computer consists of datapat ...

  3. 杭电oj题目题型分类(转)

    1001 整数求和 水题 1002 C语言实验题--两个数比较 水题 1003 1.2.3.4.5... 简单题 1004 渊子赛马 排序+贪心的方法归并 1005 Hero In Maze 广度搜索 ...

  4. HDOJ题目分类大全

    版权声明:本文为博主原创文章,欢迎转载,转载请注明本文链接! https://blog.csdn.net/qq_38238041/article/details/78178043 杭电里面有很多题目, ...

  5. HDU题目分类大全【大集合】

    基础题: 1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.  1032.1037.1040.1048.1056.105 ...

  6. 杭电OJ题目分类(转载)

    1001 整数求和 水题 1002 C语言实验题--两个数比较 水题 1003 1.2.3.4.5... 简单题 1004 渊子赛马 排序+贪心的方法归并 1005 Hero In Maze 广度搜索 ...

  7. hdoj杭电问题分类

    杭电上的题虽然多,但是一直苦于找不到问题分类,网页都是英文的,所以平时做题也没怎么看,今天仔细一看,问题分类竟然就在主页....做了那么久的题居然没发现,表示已经狗带..不要笑,不知道有没有像我一样傻 ...

  8. 转载:Hdu 题目分类

    原址点击 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056. ...

  9. HD OJ 题目分类

    动态规划:2037 2054 2084 hdu题目分类(转) http://blog.csdn.net/vsooda/article/details/7258791 1001 整数求和 水题 1002 ...

最新文章

  1. apollo在liunx环境实战(三)
  2. linux解压文件名乱码,linux下解压zip文件时,文件名乱码的解决(转载)
  3. 使用 yo 命令行向导给 SAP UI5 应用添加一个新的视图
  4. IOS开发之JSON文件的读写
  5. P2598-狼和羊的故事【最大流,最小割】
  6. Oracle JRockit Mission Control 4.1发布
  7. [bug] uni-app 支付宝小程序 上传文件uni.uploadFile 报错 errMsg: “uploadFile:fail 无效参数“
  8. bzoj 4551[Tjoi2016Heoi2016]树
  9. C#LeetCode刷题-队列
  10. 2017.5.8 文化之旅 思考记录
  11. CopyTranslator v0.0.8 Zouwu RC1 发布
  12. 1000道Python题库系列分享
  13. 计划doing.....
  14. 什么是冷区热区_火灾热区冷区
  15. 1日元是多少人民币(2014年04月23日)
  16. validate简介及使用方法与默认的校验规则
  17. springboot+pagehelper踩坑,PageHelper.startPage没有生效问题
  18. 利用手机距离感应器来切换是用扬声器听音乐还是听筒听音乐
  19. iOS-OC-提交审核:Missing Push Notification Entitlement
  20. 电源纹波和噪声及其测量和改善方法

热门文章

  1. indesign拖进去颜色变灰_INDESIGN CS4第5章 颜色与透明
  2. 域控制器丢失NETLOGON目录的解决办法
  3. CS224W图机器学习笔记8-图神经网络三大应用
  4. 钉钉添加代收邮箱地址
  5. 分布式期货行情交易系统-行情及交易模块分析
  6. 计算机程序设计论文2万字,【程序设计论文】核心素养下的计算机程序设计教学(共4049字)...
  7. 英语学习-综合英语(1)
  8. 全面掌握前端框架Vue.js
  9. 原生js实现小方块拖拽
  10. ADSP21489 Target halted due to software breakpoint but no breakpoint found at address: 0x208c0b6 ()