ZOJ 3622 Magic Number 打表找规律
Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
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 打表找规律的更多相关文章
- [ZOJ 3622] Magic Number
Magic Number Time Limit: 2 Seconds Memory Limit: 32768 KB A positive number y is called magic n ...
- ZOJ 3622 Magic Number(数)
题意 假设一个正整数y满足 将随意正整数x放到y的左边得到的数z满足 z%y==0 那么这个数就是个Magic Number 给你一个范围 求这个范围内Magic Number的个数 令 ...
- 【ZOJ】3785 What day is that day? ——浅谈KMP在ACM竞赛中的暴力打表找规律中的应用
转载请声明出处:http://www.cnblogs.com/kevince/p/3887827.html ——By Kevince 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这 ...
- 【ZOJ】3785 What day is that day? ——KMP 暴力打表找规律
转自:http://www.cnblogs.com/kevince/p/3887827.html 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这么一说大家心里肯定有数了吧,“不就是nex ...
- Codeforces 193E - Fibonacci Number(打表找规律+乱搞)
Codeforces 题目传送门 & 洛谷题目传送门 蠢蠢的我竟然第一眼想套通项公式?然鹅显然 \(5\) 在 \(\bmod 10^{13}\) 意义下并没有二次剩余--我真是活回去了... ...
- hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)
Nim or not Nim? Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Sub ...
- HDU 4861 Couple doubi (数论 or 打表找规律)
Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a ...
- OpenJ_POJ C16D Extracurricular Sports 打表找规律
Extracurricular Sports 题目连接: http://acm.hust.edu.cn/vjudge/contest/122701#problem/D Description As w ...
- OpenJ_POJ C16B Robot Game 打表找规律
Robot Game 题目连接: http://acm.hust.edu.cn/vjudge/contest/122701#problem/B Description Sgeoghy has addi ...
随机推荐
- numpy细碎知识点
np.random.rand() 基于python自带模块random的random函数的一个延伸吧,生成指定数量的列表 np.random.rand(a,b) 参数a,b均为整型,生成含有a个元素的 ...
- HttpClient使用
1.HttpClient 是 Apache Jakarta Common 下的子项目,可以用来提供高效的.最新的.功能丰富的支持 HTTP 协议的客户端编程工具包 2.主要的功能 (1)实现了所有 H ...
- scala tuple中的syntactic sugar
List[Tuple2[String, Int]] // Base List[(String, Int)] // Syntactic sugar List[Tuple3[String, Float, ...
- 5 个非常有用的 Laravel Blade 指令,你用过哪些?
接下来我将带大家认识下五个 Laravel Blade 指令,这些指令将让你在解决特定问题时如虎添翼.如果你是刚接触 Laravel 的用户,这些小技巧能带你认识到 Laravel Blade 模板引 ...
- 题解-python-CodeForces 1A
A. Theatre Square time limit per test 2 seconds memory limit per test 64 megabytes input standard in ...
- Ninject中调用webapi卡住的情况解决
过年这两天在家做项目,把mvc升级到了5.1,webapi升级到了2.1,忽然发现一个问题,在某些页面上ajax调用webapi时会发现卡死现象,CPU也没有被占用,就是网页一些在加载也不报错,经过2 ...
- Asp.Net MVC路由调试工具-RouteDebugger
1.获取方式 第一种方法: 在程序包控制台中执行命令 PM> Install-Package routedebugger 安装成功后Web.config文件中会自动加入行 <add key ...
- ASP.NET MVC之验证终结者篇
有时候我觉得,很多人将一个具体的技术细节写的那么复杂,我觉得没有必要,搞得很多人一头雾水的,你能教会别人用就成了,具体的细节可以去查MSDN什么的,套用爱因斯坦的名言:能在网上查到的就不要去记,用的时 ...
- codeforces 603 A
题目大意:给你一个0,1串, 你可以反转一段连续的区间,问你最长的合法子串是多长, 合法字串相邻的两个不能相同. 思路:dp[ i ][ k ][ j ] 表示到第 i 个字符, 处于k这种状态, k ...
- Django实战(12):增加目录页,设定统一布局
针对上一节的新需求,界面设计师还为我们设计了一个新的界面,不仅仅是目录页,还包含了站点的整体风格,如下图: 感谢界面设计师为我们提供的“又黑又硬”的工具条,这个看起来真的很酷.下面,让我们来享用她的工 ...