题目链接:http://acm.hust.edu.cn/vjudge/contest/125004#problem/D

密码:acm

Description

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

Sample Output
Case :
Case :
Case :

分析:

第一次代码,超了应该,反正看输不出结果:

 #include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std; int main()
{
int n,i,o=,a,b;
scanf("%d", &n); for(i=;i<=n;i++)
{
scanf("%d%d", &a,&b);
int d=b,ans=; while(d%a)
{
d=d*+b;
ans++;
} printf("Case %d: %d\n", o++,ans);
}
return ;
}

修改后:

 #include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std; int main()
{
int n,i,o=,a,b;
scanf("%d", &n); for(i=;i<=n;i++)
{
scanf("%d%d", &a,&b);
int d=b,ans=,r; r=b%a;
while(r)
{
d=r*+b;
ans++;
r=d%a;
} printf("Case %d: %d\n", o++,ans);
}
return ;
}

河南多校大一训练赛 D的更多相关文章

  1. 河南多校大一训练赛 G 硬币

    题目链接:http://acm.hust.edu.cn/vjudge/contest/125004#problem/G 密码:acm Description 宇航员Bob有一天来到火星上,他有收集硬币 ...

  2. 河南多校大一训练赛 C 青蛙的约会

    题目链接:http://acm.hust.edu.cn/vjudge/contest/125004#problem/C 密码:acm Description 两只青蛙在网上相识了,它们聊得很开心,于是 ...

  3. 河南多校大一训练赛 E 开餐馆

    题目链接:http://acm.hust.edu.cn/vjudge/contest/125004#problem/E 密码:acm Description 北大信息学院的同学小明毕业之后打算创业开餐 ...

  4. 2014 多校联合训练赛6 Fighting the Landlords

    本场比赛的三个水题之一,题意是两个玩家每人都持有一手牌,问第一个玩家是否有一种出牌方法使得在第一回和对方无牌可出.直接模拟即可,注意一次出完的情况,一开始没主意,wa了一发. #include< ...

  5. 河南多校联合训练 南阳理工 1261 音痴又音痴的LT

    描述 LT最近一直在无限循环薛之谦的歌,简直都中毒了!可是呢…他的歌LT还是不会唱(其实不止他的歌LT不会唱,所有人的歌LT都不会唱…因为LT是标准的音痴)可是LT又很喜欢唱歌(所以LT不仅是音痴还是 ...

  6. 河南多校联合训练 F 不是匹配

    描述  有N个人,N个活动, 每个人只会对2个或者3个活动感兴趣,  每个活动也只有两个人或者两个活动对它兴趣,每个人参加一个  感兴趣的活动需要一天 ,且当天该活动被参加时,其他的人不能参加  如果 ...

  7. hdu 5381 The sum of gcd 2015多校联合训练赛#8莫队算法

    The sum of gcd Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) T ...

  8. 2015多校联合训练赛 Training Contest 4 1008

    构造题: 比赛的时候只想到:前面一样的数,后面 是类似1,2,3,4,5,6....t这 既是:t+1,t+1...,1,2,3,...t t+1的数目 可能 很多, 题解时YY出一个N 然后对N   ...

  9. hdu 5358 First One 2015多校联合训练赛#6 枚举

    First One Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Tota ...

随机推荐

  1. mongodb安装 win7版

    首先下载mongdb的zip包,可以到:http://www.mongodb.org/downloads.选择32位或64位的. 在D盘创建mongodb文件夹,d:\mongodb.把解压里面所有的 ...

  2. SIM卡信息的管理

    MTK平台上,所有插入到手机中的SIM卡的信息都会存储在数据库com.android.providers.telephony中. 原始的数据库 图表 1 SimInfo数据表的结构 从上图示中,我们可 ...

  3. SEO优化技巧总结

    SEO优化技巧总结 一:了解搜索引擎 基础知识 搜索引擎:由蜘蛛程序沿着链接爬行和抓取网上的大量页面,存进数据库,经过预处理,用户在搜索框 输入关键词后,搜索引擎排序从数据库中挑选出符合搜索关键词要求 ...

  4. 第19讲 不带参数功能FC的编程与应用

  5. 给windows共享 目录付于权限

    1.点右监 共享给 某用户 2.点属性 -> 安全 加入  特定用户 3.域用户的管理 (选择控制面板/用户管理) 第一个用户是本地账户 第2/3个是域用户

  6. 项目管理实践【四】Bug跟踪管理【Bug Trace and Management】

    首先,向大家说一声抱歉,这篇文章耽误了这么久才和大家见面.至于Bug的跟踪和管理的必要性和好处,我就不在这里说了,下面介绍几款Bug跟踪和管理的软件. 一.BugNET BugNET是一个非常优秀的开 ...

  7. Codeforces 691D Swaps in Permutation

    Time Limit:5000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Prac ...

  8. 典型的DIV+CSS布局——左中右版式

    [效果] [HTML] <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Def ...

  9. Office Web Apps 错误

    owa安装完后,在sharepoint网站上打开word,excel,报错,Sorry, something went wrong, 通过correlation id找到错误信息(如何在sharepo ...

  10. MJExtension的使用

    1. Plist → 模型数组 控制器中引用#import "MJExtension.h" 模型数组 = [模型类名 objectArrayWithFilename:@" ...