ZOJ3622 Magic Number(水题)

分析:

举个例子xxx(三位数)为魔力数,则xxx|(xxx+1000*y),那么xxx|1000,这个就是结论

同理:四位数xxxx|10000,五位数xxxxx|100000

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#include<queue>
#include<cstring>
#include<algorithm>
typedef long long LL;
using namespace std;

const int maxn=600005;
LL p[maxn];
int main()
{
    LL a,b;
    while(~scanf("%lld%lld",&a,&b))
    {
        LL cnt=0;
        for(LL i=10;i<1000000000000;i*=10)
        {
            for(LL j=10;j>1;j--)
                if(i%j==0&&i/j>=i/10)p[cnt++]=i/j;
        }
        sort(p,p+cnt);
        LL ans=upper_bound(p,p+cnt,b)-lower_bound(p,p+cnt,a);
        printf("%lld\n",ans);
    }
    return 0;
}
时间: 2024-08-07 21:27:27

ZOJ3622 Magic Number(水题)的相关文章

杭电(hdu)2070 Fibbonacci Number 水题

Fibbonacci Number Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 17675    Accepted Submission(s): 8422 Problem Description Your objective for this question is to develop a program which will g

HDU 4006 The kth great number (基本算法-水题)

The kth great number Problem Description Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a number, or ask Xiao Bao what the kth great number is. Because the number written by Xiao Ming is too mu

水题 HDOJ 4727 The Number Off of FFF

题目传送门 1 /* 2 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 #include <cstring> 8 #include <string> 9 #include <cmath> 10 using namespace std; 11 12 const in

hdu 3443(水题,公式)Shift Number

题意: 给一个数n,求最小的数生成的shift number等于n. shift number就是一个数x,x*10,x*100-..这样的和. 思路 把那个公式处理一下,其实就是X*(形如11111-.)这样的一个式子,那么找一个最大的11111-.,x就是最小了.水题 复杂度: O(len(n)) 参考code: /* #pragma warning (disable: 4786) #pragma comment (linker, "/STACK:0x800000") */ #in

PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚

n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题... #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; const int maxn=30; int a[maxn]; int n,b; int main() { scanf("%d %d&q

2019浙大校赛--J--Extended Twin Composite Number(毒瘤水题)

毒瘤出题人,坑了我们好久,从基本的素数筛选,到埃氏筛法,到随机数快速素数判定,到费马小定理,好好的水题做成了数论题. 结果答案是 2*n=n+3*n,特判1,2. 以下为毒瘤题目: 题目大意: 输入一个数n, 输出两个合数(即非素数)a,b 实现 n+a=b 解题思路 3n=n+2n; 特判1.2 代码: 1 #include<iostream> 2 #include<stdio.h> 3 using namespace std; 4 typedef long long ll; 5

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

HDU 1800 Flying to the Mars (水题)

Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11099    Accepted Submission(s): 3572 Problem Description In the year 8888, the Earth is ruled by the PPF Empire . As the popul

HDU4891_The Great Pan_字符串水题

2014多校第五题,当时题面上的10^5写成105,我们大家都wa了几发,改正后我和一血就差几秒…不能忍 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4891 The Great Pan Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 966    Accepted Submission(s