链接:

https://vjudge.net/problem/LightOJ-1078

题意:

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.

思路:

\((a*x+y)%b = (a%b*x%b+y%b)%b\)

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector> using namespace std;
typedef long long LL;
const int INF = 1e9; const int MAXN = 1e6+10;
const int MOD = 1e9+7; int main()
{
int t, cnt = 0;
LL n, x;
scanf("%d", &t);
while(t--)
{
scanf("%lld%lld", &n, &x);
printf("Case %d: ", ++cnt);
if (x%n == 0)
puts("1");
else
{
int cnt = 1;
int tmp = x;
while(x!=0)
{
x = (x*10+tmp)%n;
cnt++;
}
printf("%d\n", cnt);
}
} return 0;
}

最新文章

  1. Android中常见功能包描述(转)
  2. AOP动态代理解析5-cglib代理的实现
  3. uboot在s3c2440上的移植(1)
  4. Nginx+uWSGI+Django原理
  5. linux 进入包含空格文件名的文件夹
  6. MVVM架构~knockoutjs系列之表单添加(验证)与列表操作源码开放
  7. php ajax提交数据 在本地可以执行,而在服务器不能执行
  8. C#Windows Form简易计算器实现(中)
  9. Spring阅读方法
  10. Eclipse中tomcat配置
  11. Java限流策略
  12. ArcGIS JS 3.x使用webgl绘制热力图
  13. java----字符串的大写字母右移
  14. linux centos7添加ip黑名单禁止某个ip访问
  15. 安装 jenkins
  16. Mongodb内嵌数组的完全匹配查询
  17. CentOS 几种重启方式的区别
  18. Opengl绘制我们的小屋(二)第一人称漫游
  19. paramiko 简单的使用
  20. Grid Search学习

热门文章

  1. Variational Auto-encoder(VAE)变分自编码器-Pytorch
  2. 03 CSS听课笔记
  3. [转帖]Red Hat K8s 关键人物 Grant Shipley 跳槽到 VMware
  4. php生成动态验证码 加减算法验证码 简单验证码
  5. Linux基础-01-Linux基础命令
  6. 利用Python进行数据分析 第5章 pandas入门(2)
  7. 计算机网络--TCP协议深入理解
  8. [二叉树算法]关于判断是否为BST的算法
  9. Django数据库基本操作(MySQL)
  10. mouseover mouseleave