A - Magic Number

Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu

Appoint description:
 

Description

A positive number y is called magic number if for every positive integer x it satisfies that put y to the right of x, which will form a new integer z, z mod y = 0.

Input

The input has multiple cases, each case contains two positve integers m, n(1 <= m <= n <= 2^31-1), proceed to the end of file.

Output

For each case, output the total number of magic numbers between m and n(m, n inclusively).

Sample Input

1 1
1 10

Sample Output

1
4 思路:首先我们得用数学方法推出 只要满足10^ans%a==0,就是magic数,ans指的是a这个数的位数
题解:找规律,然后人工打表……
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; int a1[] = {,,,,,,,,,};
int a2[] = {,,,,,,,,,};
int a3[] = {,,,,,,,,};
int a4[] = {,,,,,,,};
int a5[] = {,,,,,,,}; int main()
{
int ans,n,m,i;
while(~scanf("%d%d",&n,&m))
{
ans = ;
if(n>m)
swap(n,m);
for(i = ;i<;i++)
if(n<=a1[i] && a1[i]<=m)
ans++;
for(i = ;i<;i++)
if(n<=a2[i] && a2[i]<=m)
ans++;
for(i = ;i<;i++)
if(n<=a3[i] && a3[i]<=m)
ans++;
for(i = ;i<;i++)
if(n<=a4[i] && a4[i]<=m)
ans++;
for(i = ;i<;i++)
if(n<=a5[i] && a5[i]<=m)
ans++;
printf("%d\n",ans);
} return ;
}

ZOJ 3622 Magic Number 打表找规律的更多相关文章

  1. [ZOJ 3622] Magic Number

    Magic Number Time Limit: 2 Seconds      Memory Limit: 32768 KB A positive number y is called magic n ...

  2. ZOJ 3622 Magic Number(数)

    题意  假设一个正整数y满足  将随意正整数x放到y的左边得到的数z满足 z%y==0  那么这个数就是个Magic Number   给你一个范围  求这个范围内Magic Number的个数 令 ...

  3. 【ZOJ】3785 What day is that day? ——浅谈KMP在ACM竞赛中的暴力打表找规律中的应用

    转载请声明出处:http://www.cnblogs.com/kevince/p/3887827.html    ——By Kevince 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这 ...

  4. 【ZOJ】3785 What day is that day? ——KMP 暴力打表找规律

    转自:http://www.cnblogs.com/kevince/p/3887827.html 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这么一说大家心里肯定有数了吧,“不就是nex ...

  5. Codeforces 193E - Fibonacci Number(打表找规律+乱搞)

    Codeforces 题目传送门 & 洛谷题目传送门 蠢蠢的我竟然第一眼想套通项公式?然鹅显然 \(5\) 在 \(\bmod 10^{13}\) 意义下并没有二次剩余--我真是活回去了... ...

  6. hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)

    Nim or not Nim? Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  7. HDU 4861 Couple doubi (数论 or 打表找规律)

    Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a ...

  8. OpenJ_POJ C16D Extracurricular Sports 打表找规律

    Extracurricular Sports 题目连接: http://acm.hust.edu.cn/vjudge/contest/122701#problem/D Description As w ...

  9. OpenJ_POJ C16B Robot Game 打表找规律

    Robot Game 题目连接: http://acm.hust.edu.cn/vjudge/contest/122701#problem/B Description Sgeoghy has addi ...

随机推荐

  1. linux系统iostat命令详解

    iostat  -k 3 5  (以KB为单位,每3秒统计一次,共统计5次) • avg-cpu: 总体cpu使用情况统计信息,对于多核cpu,这里为所有cpu的平均值    %user    用户空 ...

  2. 使用Netty4实现基本的消息分发

    示例工程代码 可从附件下载 具体的说明和用法在后面介绍 需求与目的 一个游戏服务端需要处理各种业务逻辑,每一种业务逻辑都对应着一个请求消息和一个响应消息.那么服务端需要把这些不同的消息自动分发到对应的 ...

  3. C++之插入迭代器

    #include<iostream> #include<vector> #include<list> #include<iterator> usingn ...

  4. 【笔记】Python简明教程

    Python简明教程,此资源位于http://woodpecker.org.cn/abyteofpython_cn/chinese/ s=u'中文字符' #u表示unicode,使用u之后能正常显示中 ...

  5. SSIS 学习之旅 第一个SSIS 示例(二)

    这一章还是继上一章例子 进行一些小的知识扩展.主要是为了让大家更快的上手SSIS. 概要设计:    1.按用户组生成CSV文件到Pending目录下,    2.移动Pending目录下的CSV文件 ...

  6. hdu 4349 求C(n,0),C(n,1),C(n,2)...C(n,n).当中有多少个奇数 (Lucas定理推广)

    Lucas定理:把n写成p进制a[n]a[n-1]a[n-2]...a[0],把m写成p进制b[n]b[n-1]b[n-2]...b[0],则C(n,m)与C(a[n],b[n])*C(a[n-1], ...

  7. Python3语法详解

    一.下载安装 1.1Python下载 Python官网:https://www.python.org/ 1.2Python安装 1.2.1 Linux 平台安装 以下为在Unix & Linu ...

  8. 【58沈剑架构系列】互联网公司为啥不使用mysql分区表?

    缘起:有个朋友问我分区表在58的应用,我回答不出来,在我印象中,百度.58都没有听说有分区表相关的应用,业内进行一些技术交流的时候也更多的是自己分库分表,而不是使用分区表.于是去网上查了一下,并询问了 ...

  9. Spring的配置文件ApplicationContext.xml配置头文件解析

    Spring的配置文件ApplicationContext.xml配置头文件解析 原创 2016年12月16日 14:22:43 标签: spring配置文件 5446 spring中的applica ...

  10. bzoj 1263 [SCOI2006]整数划分

    n >= 6 的时候减3, 最后分类讨论, 上个Java import java.math.BigInteger; import java.util.*; public class Main { ...