ZOJ 3622 Magic Number 水题
#include <set> #include <map> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <cctype> #include <cstdio> #include <string> #include <vector> #include <cassert> #include <cstdlib> #include <cstring> #include <sstream> #include <iostream> #include <algorithm> using namespace std; int max(int a,int b){return a<b?b:a;} int min(int a,int b){return a>b?b:a;} long long x[55]={ 1,2,5,10,20,25,50, 100,125,200,250,500, 1000,1250,2000,2500,5000, 10000,12500,20000,25000,50000, 100000,125000,200000,250000,500000, 1000000,1250000,2000000,2500000,5000000, 10000000,12500000,20000000, 25000000, 50000000, 100000000 ,125000000, 200000000, 250000000, 500000000, 1000000000 ,1250000000, 2000000000, 2500000000,5000000000, 10000000000 ,12500000000, 20000000000}; int main() { long long n,a,b,i; while(scanf("%lld%lld",&a,&b)!=EOF) { n=0; for(i=0;i<54;i++) { if(x[i]>=a&&x[i]<=b) n++; if(x[i]>b) break; } printf("%lld\n",n); } return 0; }
形如AB的数,求出n,m之间满足AB%B==0 数
找出规律后暴力枚举