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. my.cnf 详解与优化【转】

    MySQL配置文件my.cnf 例子最详细翻译,可以保存做笔记用. #BEGIN CONFIG INFO#DESCR: 4GB RAM, 只使用InnoDB, ACID, 少量的连接, 队列负载大#T ...

  2. JAVA_OPTS讲解【转】

    JAVA_OPTS ,顾名思义,是用来设置JVM相关运行参数的变量. JAVA_OPTS="-server -Xms256m -Xmx512m -XX:PermSize=64M -XX:Ma ...

  3. ASP.net-空白页的问题

    protected void Application_Error(object sender, EventArgs e)         {             ILog log = LogMan ...

  4. ModelState验证部分属性

    ModelState.Remove("Name") 去掉不需要验证的属性.

  5. Pytorch数据读取框架

    训练一个模型需要有一个数据库,一个网络,一个优化函数.数据读取是训练的第一步,以下是pytorch数据输入框架. 1)实例化一个数据库 假设我们已经定义了一个FaceLandmarksDataset数 ...

  6. Luogu P3384 【【模板】树链剖分】

    转载请注明出处,部分内容引自banananana大神的博客 ~~别说你不知道什么是树~~╮(─▽─)╭(帮你百度一下) 先来回顾两个问题:1,将树从x到y结点最短路径上所有节点的值都加上z 这也是个模 ...

  7. 压力测试随笔之:JMeter,LoadRunner 相得益彰

    做压力测试,我喜欢先写 JMeter 脚本,功能测通以后再翻译成 LoadRunner 脚本,最后用 LoadRunner 完成压测.也许我是 Java 出身吧,对 JMeter 总是有一种亲切感用着 ...

  8. Docker容器跨主机通信之:直接路由方式

    一.Docker网络基本原理 直观上看,要实现网络通信,机器需要至少一个网络接口(物理接口或虚拟接口)与外界相通,并可以收发数据包:此外,如果不同子网之间要进行通信,需要额外的路由机制. Docker ...

  9. MySQL学习笔记:生成时间维度表2

    实现目的: 测试: # 测试 加一秒 SECOND), INTERVAL SECOND); SECOND),'%H%i%s');# 第一秒 SECOND),'%H%i%s');# 最后一秒 SELEC ...

  10. Effective API Design

    Effective API Design */--> div.org-src-container { font-size: 85%; font-family: monospace; } Tabl ...