LIGHTOJ-1078 - Integer Divisibility
来源:互联网 发布:mac天翼飞young连不上 编辑:程序博客网 时间:2024/05/16 14:07
If an integer is not divisible by 2 or 5, some multiple of that number in decimal notation is a sequence of only a digit. Now you are given the number and the only allowable digit, you should report the number of digits of such multiple.
For example you have to find a multiple of 3 which contains only 1's. Then the result is 3 because is 111 (3-digit) divisible by 3. Similarly if you are finding some multiple of 7 which contains only 3's then, the result is 6, because 333333 is divisible by 7.
Input
Input starts with an integer T (≤ 300), denoting the number of test cases.
Each case will contain two integers n (0 < n ≤ 106 and n will not be divisible by 2 or 5) and the allowable digit (1 ≤ digit ≤ 9).
Output
For each case, print the case number and the number of digits of such multiple. If several solutions are there; report the minimum one.
Sample Input
Output for Sample Input
3
3 1
7 3
9901 1
Case 1: 3
Case 2: 6
Case 3: 12
求几个一位数能被第一个数整除,模拟两数相除的过程!
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){int i,j,k,a,b,m,n,num1,num2,cot=1;;scanf("%d",&n);while(n--){num1=0;num2=0;scanf("%d%d",&a,&b);int x=a,y=b;while(x>y){y=y*10+b;num2++;}while(y%x){y=(y%x)*10+b;num1++;}printf("Case %d: %d\n",cot++,num1+num2+1);}return 0;}
- LIGHTOJ-1078 - Integer Divisibility
- LightOJ-1078 Integer Divisibility
- 【简单】LightOJ Integer Divisibility 1078
- lightoj 1078 - Integer Divisibility 【同余】
- LightOJ 1078 - Integer Divisibility (同余定理)
- lightoj 1078 - Integer Divisibility 【同余定理】
- LightOJ 1078 - Integer Divisibility【同余】
- lightoj 1078 - Integer Divisibility 暴力数学
- lightoj-1078-Integer Divisibility【大数除法】
- 【 LightOJ 1078 Integer Divisibility + 同余定理 】
- LightOJ 1078 Integer Divisibility (同余定理)
- LightOJ 1078 - Integer Divisibility(取模运算)
- LightOJ 1078 Integer Divisibility (同余定理)
- LightOJ 1078 Integer Divisibility (同余定理 )
- 【Light】[1078]Integer Divisibility
- 1078 - Integer Divisibility
- light--oj--1078 - Integer Divisibility
- Light OJ 1078:Integer Divisibility
- Android 4.4前后版本读取图库图片和拍照完美解决方案
- 预处理详解
- 开源框架:SDWebImage
- android(8)(获取手机系统内存和SD卡内存信息)
- [IOS] No provisioning profiles with a valid siging identity
- LIGHTOJ-1078 - Integer Divisibility
- 启动tocat时,就运行程序里的某个方法
- SQL中常用函数集合
- flog
- 关于uitableview上面的一块空白的问题
- 如何使用xcode生成.ipa文件
- Hibernate学习笔记一
- android典型代码系列(十)------获取一个应用程序的权限信息(反射)
- Java 大作业回忆--day02-- PC端的初次尝试