Problem:
ハミング数
1 に 2, 3, 5 を何回か (0 回以上) かけ算して得られる数をハミング数 (Hamming numbers) と呼びます。例えば、
1
1 × 2 × 2 = 4
1 × 2 × 2 × 3 × 5 × 5 = 300
などはハミング数ですが、11, 13, 14 などはハミング数ではありません。
ハミング数はどれも 60 のべき乗を割り切る(例えば、54 は 60
3
= 21600 を割り切る) ので、時刻など 60 進法の計算には都合の良い数として昔から知られていました。また、楽器の調律に用いる音階の一つである純正律では、音の周波数の比が 24, 27, 30, 32, 36, 40, 45, 48 というハミング数からなる数列になります。
整数
m
、
n
を入力とし、
m
以上
n
以下のハミング数の個数を出力するプログラムを作成してください。
Input
複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。
各データセットとして、２つの整数
m
と
n
(1 ≤
m
,
n
≤ 1000000,
m
≤
n
) が空白区切りで１行に与えられます。
データセットの数は 20 を超えません。
Output
データセットごとに
m
以上
n
以下のハミング数の個数を１行に出力します。
Sample Input
3 8
1 27
1 86
0
Output for the Sample Input
5
17
31

Submitted solutions:

code_snippet: #include <iostream>
using namespace std;
int main() {
  int n, m;
  while (cin >> m, m) {
    cin >> n;
    int ans = 0;
    for (; m <= n; m++) {
      int tmp = m;
      while (!(tmp % 2))
        tmp /= 2;
      while (!(tmp % 3))
        tmp /= 3;
      while (!(tmp % 5))
        tmp /= 5;
      if (tmp == 1)
        ans++;
    }
    cout << ans << endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3052
final_rank: 3

code_snippet: #include <iostream>
using namespace std;
int main() {
  int n, m, ret;
  while (cin >> n && n) {
    cin >> m;
    ret = 0;
    for (int i = n; i <= m; i++) {
      int c = i;
      while (c % 2 == 0) {
        c /= 2;
      }
      while (c % 3 == 0) {
        c /= 3;
      }
      while (c % 5 == 0) {
        c /= 5;
      }
      if (c == 1)
        ret++;
    }
    cout << ret << endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3076
final_rank: 8

code_snippet: #include <iostream>
using namespace std;
int main() {
  int n, m, ret, c;
  while (cin >> n && n) {
    cin >> m;
    ret = 0;
    for (int i = n; i <= m; i++) {
      c = i;
      while (c % 2 == 0) {
        c /= 2;
      }
      while (c % 3 == 0) {
        c /= 3;
      }
      while (c % 5 == 0) {
        c /= 5;
      }
      if (c == 1)
        ret++;
    }
    cout << ret << endl;
  }
}
accuracy: 1
time_ms: 20
memory_kb: 3076
final_rank: 11

code_snippet: #include <iostream>
using namespace std;
const int MAX = 1000000;
bool hamming[MAX];
int main() {
  int ps[3] = {2, 3, 5};
  int n, m;
  for (int i = 0; i < MAX; ++i) {
    n = i + 1;
    for (int j = 0; j < 3; ++j) {
      while (n % ps[j] == 0)
        n /= ps[j];
    }
    hamming[i] = n == 1 ? true : false;
  }
  while (cin >> m, m) {
    cin >> n;
    int c = 0;
    --m;
    for (int i = m; i < n; ++i) {
      if (hamming[i])
        ++c;
    }
    cout << c << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4052
final_rank: 12

code_snippet: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>

using namespace std;

template<class T, class Func = function<T(T, T)>>
class segtree {
    vector<T> obj;
    int offset;
    Func updater;
    T e;
    int bufsize(int num) {
        int i = 1;
        for (; num  + 1 > i; i <<= 1);
        offset = i - 1;
        return (i << 1) - 1;
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return e;
        if (a <= l && r <= b)return obj[k];
        else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
    }
    int find_maximum_index_sub(int a, int b, T x, int k,int l, int r,const Func& f){
        if(!f(obj[k],x) || r <= a || b <= l) return -1;
        if(k >= offset) return k - offset;
        /* search * right *  subtree to find x*/
        int rv = find_maximum_index_sub(a,b,x,2 * k + 2, (l + r) / 2,r,f);
        if(rv  !=  -1) return rv;
        /* find maximum ( right ) index, so that left subtree will be searched only if  there is no elem in right subtree*/
        return find_maximum_index_sub(a,b,x, 2 * k + 1, l, (l + r) / 2,f);
    }
    int find_minimum_index_sub(int a, int b, T x, int k, int l, int r,const Func& f){
        if(!f(obj[k],x) || r <= a || b <= l) return -1;
        if(k >= offset) return k - offset;
        /* search * right *  subtree to find x*/
        int lv = find_minimum_index_sub(a,b,x, 2 * k + 1, l, (l + r) / 2,f);
        if(lv  !=  -1) return lv;
        /* find maximum ( right ) index, so that left subtree will be searched only if  there is no elem in right subtree*/
        return find_minimum_index_sub(a,b,x,2 * k + 2, (l + r) / 2,r,f);
    }
public:
    T query(int a, int b) {//[a,b)
        return query(a, b, 0, 0, offset + 1);
    }
    void updateall(int l = 0, int r = -1) {
        if (r < 0)r = offset + 1;
        l += offset, r += offset;
        do {
            l = (l - 1) >> 1, r = (r - 1) >> 1;
            for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]);
        } while (l);
    }
    void update(int k, T a) {
        k += offset;
        obj[k] = a;
        while (k) {
            k = (k - 1) >> 1;
            obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]);
        }
    }
    //[l,r)
    int find_maximum_index(int l, int r, T x,const Func& f) {
        return find_maximum_index_sub(l,r,x,0,0,offset + 1,f);
    }
    // (l,r]
    int find_minimum_index(int l, int r, T x,const Func& f){
        return find_minimum_index_sub(l,r,x,0,0,offset + 1,f);
    }
    void print_tree(){
        int id = 0;
        int sum = obj.size();
        for(int i = 0;sum > 0 ; ++i){
            for(int j = 0; j < (1 << i); ++j){
                cout << obj[id++] << " ";
                --sum;
            }
            cout << endl;
        }
    }
    
    segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {}
    segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) {
        copy(vec.begin(), vec.end(), obj.begin() + offset);
        updateall();
    }
    typename vector<T>::reference operator[](int n) {
        return obj[n + offset];
    }
    void set(int id, T x){
        update(id,x);
    }
};
using Int = short;
int maxim = 1e6 + 1;
int main(){
    vector<Int>dp(5 * maxim + 1,0);
    dp[1] = 1;
    for(int i = 1; i < maxim; ++i){
        if(dp[i] == 0)continue;
        dp[i * 2] = dp[i * 3] = dp[i * 5] = 1;
    }
    auto sgt = segtree<Int>(dp,0LL,plus<>());
    while(true){
        int l,r;cin >> l;
        if(l == 0) break;
        cin >> r;
        cout << sgt.query(0,r + 1) - sgt.query(0,l) << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 45332
final_rank: 19

code_snippet: #include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF (1LL<<40)
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define MP make_pair
#define int long long
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define umap unordered_map 
#define re0 return 0
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
 int dx[]={0,1,0,-1};
 int dy[]={1,0,-1,0};
//typedef pair<int,int> P;
const string SP = " ";
const string TAB = "\t"; 
const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}
bool is_kaibun(string s){string rs = s;reverse(all(rs));if(s == rs)return true;else return false;}
std::random_device rnd;
std::mt19937 mt(rnd());
const int RAND_LIMIT = 1000000;
std::uniform_int_distribution<> rand_mt(0, RAND_LIMIT); // rand_mt(mt);

inline double getTime() {
    using namespace std::chrono;
    return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
}
template<typename T> bool chmax(T &m, const T q) {
    if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) {
    if (m > q) {m = q; return true;} else return false; }


template<typename T> 
void printv(vector<T> v, bool is_endl=true){
    for(int i=0;i<v.size();i++){
        if(i)cout<<" ";
        cout<<v[i];
    }
    if(is_endl)cout<<endl;
}
//int INF=1e18;

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
// struct Point{
//     int x,y,num;

//     double e_dis(Point other){
//         return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y));
//     }
// };

int gcd(int a,int b){
    if(b==0)return a;
    else return gcd(b,a%b);
}

bool is_prime(int x){
  if(x==1)return 0;
  if(x==2)return 1;
  for(int i=2;i*i<=x;i++)if(x%i==0)return 0;
  return 1;
}

//スプリット関数
//split(文字列変数,区切りたい文字);
vector<string> split(string s, char c){
    if(s[s.size()-1]!=c)s+=c;
    vector<string> v;
    int pos=0;
    rep(i,0,s.size()){
        if(s[i]==c){
            v.push_back(s.substr(pos,i-pos));
            pos=i+1;
        }
        if(i==s.size()-1 && s.substr(pos,i-pos)!="")v.push_back(s.substr(pos,i-pos));
    }
    return v;
}

map<int,int> prime_factor(int n){
    map<int,int> ret;
    if(n==1){
        ret[1]=1;
        return ret;
    }
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            ret[i]++;
            n/=i; 
        }
    }
    if(n!=1)ret[n]=1;
    return ret;
}

struct UnionFind{
    vector<int> par;
    UnionFind(int n){
        par.assign(n,-1);
    }
    int root(int x){
        if(par[x]<0)return x;
        else return par[x]=root(par[x]);
    }

    bool same(int a,int b){
        return root(a)==root(b);
    }

    bool merge(int a,int b){
        a=root(a);
        b=root(b);
        if(a==b)return false;

        if(par[a]>par[b])swap(a,b);
        par[a]+=par[b];
        par[b]=a;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

vector<bool> eratos(int n){
    vector<bool> prime(n,true);
    prime[0]=false;
    prime[1]=false;
    for(int i=2;i<=n;i++){
        if(prime[i]){
            for(int j=i+i;j<=n;j+=i){
                prime[j]=false;
            }
        }
    }
    return prime;
}

int n,m;
map<int,int> mp;
void dfs(int x){
    if(m <= x && x <= n) mp[x] = 1;
    if(2*x <= n)dfs(2*x);
    if(3*x <= n)dfs(3*x);
    if(5*x <= n)dfs(5*x);
    return;
}


signed main(){
    while(cin>>m>>n){
        if(n+m==0)break;
        mp.clear();
        dfs(1);
        cout<<mp.size()<<endl;
    }
}
/*

*/
accuracy: 1
time_ms: 50
memory_kb: 3380
final_rank: 14

code_snippet: #include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<list>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<iomanip>
#include<regex>
#include<random>
using namespace std;
#define int long long
#define uint unsigned long long
const int mod=1e9+7;
const int inf=mod*mod;
const double eps=1e-9;
signed main(){
	int m,n;
	while(cin>>m>>n){
		int cnt=0;
		for(int i=m;i<=n;i++){
			int ii=i;
			for(int j=2;j<=5;j++)
				while(ii%j==0)
					ii/=j;
			if(ii==1)
				cnt++;
		}
		cout<<cnt<<endl;
	}
}
accuracy: 1
time_ms: 160
memory_kb: 3360
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
char inverse_char(char c) {
  if(isupper(c)) return tolower(c);
  else return toupper(c);
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

struct SieveOfEratosthenes : std::vector<int> {
  std::vector<int> primes;
  SieveOfEratosthenes(int MAXN) : std::vector<int>(MAXN + 1) {
    std::iota(begin(), end(), 0);
    for (int i = 2; i <= MAXN; i++) {
      if ((*this)[i] == i) {
        primes.push_back(i);
        for (int j = i; j <= MAXN; j += i) (*this)[j] = i;
      }
    }
  }
  using T = long long int;
  // Prime factorization for x <= MAXN^2
  // Complexity: O(log x)          (x <= MAXN)
  //             O(MAXN / logMAXN) (MAXN < x <= MAXN^2)
  std::map<T, int> Factorize(T x) {
    assert(x <= 1LL * (int(size()) - 1) * (int(size()) - 1));
    std::map<T, int> ret;
    if (x < int(size())) {
      while (x > 1) {
        ret[(*this)[x]]++;
        x /= (*this)[x];
      }
    }
    else {
      for (auto p : primes) {
        while (!(x % p)) x /= p, ret[p]++;
        if (x == 1) break;
      }
      if (x > 1) ret[x]++;
    }
    return ret;
  }
  std::vector<T> Divisors(T x) {
    std::vector<T> ret{1};
    for (auto p : Factorize(x)) {
      int n = ret.size();
      for (int i = 0; i < n; i++) {
        for (T a = 1, d = 1; d <= p.second; d++) {
          a *= p.first;
          ret.push_back(ret[i] * a);
        }
      }
    }
    return ret; // Not sorted
  }
  // Moebius function Table
  // return: [0=>0, 1=>1, 2=>-1, 3=>-1, 4=>0, 5=>-1, 6=>1, 7=>-1, 8=>0, ...]
  std::vector<int> GenerateMoebiusFunctionTable() {
    std::vector<int> ret(size());
    for (int i = 1; i < int(size()); i++) {
      if (i == 1) ret[i] = 1;
      else if ((i / (*this)[i]) % (*this)[i] == 0) ret[i] = 0;
      else ret[i] = -ret[i / (*this)[i]];
    }
    return ret;
  }
};
SieveOfEratosthenes sieve(1000000);

ll ham(ll a) {
  ll ans = 0;
  for(int i = 1; i <= a; ++i) {
    bool f = false;
    auto x = sieve.Factorize(i);
    for(auto p : x) { // 素因数分解したい値をかっこの中へ。
      if(p.first != 2 && p.first != 3 && p.first != 5) f = true;
    }
    if(f == false) ans++;
  }
  return ans;
}

int main() {
  while(true) {
    int m, n; cin >> m;
    if(m == 0) {
      return 0;
    }
    cin >> n;
    cout << ham(n) - ham(m - 1) << endl;
  }
}
accuracy: 1
time_ms: 320
memory_kb: 7428
final_rank: 20

code_snippet: #include <iostream>
#include <stdio.h>

#define MAX_n 1'000'000

using namespace std;

int m, n;
int cnt[MAX_n + 1];
int fct[] = {2, 3, 5};

int main() {
  cnt[0] = 0;
  cnt[1] = 1;
  for (int i = 2; i <= MAX_n; ++i) {
    int t = i;
    for (int j = 0; j < 3; ++j) {
      while (t % fct[j] == 0) {
        t /= fct[j];
      }
    }
    if (t == 1) {
      cnt[i] = cnt[i - 1] + 1;
    } else {
      cnt[i] = cnt[i - 1];
    }
  }

  for (;;) {
    cin >> m;
    if (m == 0) {
      break;
    }
    cin >> n;
    printf("%d\n", cnt[n] - cnt[m - 1]);
  }
}
accuracy: 1
time_ms: 20
memory_kb: 6996
final_rank: 13

code_snippet: #include<iostream>
using namespace std;
bool f(int a){
	while(a%3<1)a/=3;
	while(a%5<1)a/=5;
	return __builtin_popcount(a)==1;
}
main(){
	int m,n;
	while(cin>>m,m){
		cin>>n;int cnt=0;
		for(;m<=n;m++)cnt+=f(m);
		cout<<cnt<<endl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3068
final_rank: 6

code_snippet: #include <iostream>

int isHamming(int n)
{
	while (n%2==0) n/=2;
	while (n%3==0) n/=3;
	while (n%5==0) n/=5;
	return (n==1) ? 1 : 0;
}

int main()
{
	int m, n;
	while (true) {
		std::cin >> m;
		if (m==0) break;
		std::cin >> n;
		int res = 0;
		for (int i=m; i<=n; i++) {
			res += isHamming(i);
		}
		std::cout << res << std::endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3060
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int m,n;
    while (cin>>m>>n) {
        if (m==0) {
            break;
        } else {
            int count=0;
            for (int i=m;i<=n;i++) {
                int tmp=i;
                if (tmp%2==0) {
                    while (tmp%2==0) {
                        tmp=tmp/2;
                    }
                    while (tmp%3==0) {
                        tmp=tmp/3;
                    }
                    while (tmp%5==0) {
                        tmp=tmp/5;
                    }
                    if (tmp==1) {
                        count++;
                    }
                } else {
                    while (tmp%3==0) {
                        tmp=tmp/3;
                    }
                    while (tmp%5==0) {
                        tmp=tmp/5;
                    }
                    if (tmp==1) {
                        count++;
                    }
                }
            }
            cout<<count<<endl;
        }
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3056
final_rank: 4

code_snippet: #include <cstdio>
using namespace std;

bool is_valid(int num) {
    while(num % 2 == 0) num /= 2;
    while(num % 3 == 0) num /= 3;
    while(num % 5 == 0) num /= 5;
    return num == 1;
}

int solve_testcase() {
    int L; scanf("%d", &L);
    if(L == 0) return 1;
    int R; scanf("%d", &R);

    int ans = 0;
    for(int i=L; i<=R; i++) ans += is_valid(i);
    printf("%d\n", ans);
    
    return 0;
}

int main() {
    while(!solve_testcase());
}
accuracy: 1
time_ms: 10
memory_kb: 2688
final_rank: 1

code_snippet: #include<iostream>
using namespace std;
int main(){
    int n,m;
    while(cin >> n,n){
        cin >> m;
        int ans = 0;
        for(int i = n; i <= m; i++){
            int t = i;
            while(t % 2 == 0)t /= 2;
            while(t % 3 == 0)t /= 3;
            while(t % 5 == 0)t /= 5;
            if(t == 1)ans++;
        }
        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3092
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=5000000000000000000;
ll MOD=1000000007;


int main() {
    vector<int> dp(1000001),s(1000001);
    s.at(0)=0;
    queue<int> q;
    q.push(1);
    while (!q.empty()){
        int a=q.front();
        q.pop();
        if (a>1000000) continue;
        dp[a]=1;
        q.push(a*2);
        q.push(a*3);
        q.push(a*5);
    }
    for (int i=1;i<1000001;i++){
        s.at(i)=s.at(i-1)+dp.at(i);
    }
    while (true){
    int t,y;
    cin >> t;
    if (t==0) return 0;
    cin >>y;
    cout << s.at(y)-s.at(t-1) << endl;
}
}
accuracy: 1
time_ms: 20
memory_kb: 15980
final_rank: 17

code_snippet: #include<iostream>
using namespace std;

int main()
{
    int m, n;

    while( cin >> m )
    {
        if( m == 0 )
            break;
        
        cin >> n;
        
        int cnt = 0;

        for( int i = m; i <= n; i++ )
        {
            int j = i;
            while( j % 2 == 0 )
                j /= 2;
            while( j % 3 == 0 )
                j /= 3;
            while( j % 5 == 0 )
                j /= 5;
            if( j == 1 )
                cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3048
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


const int MAX = 1e6;
int dp[MAX+1], s[3] = {2, 3, 5};
signed main(){
  dp[1] = 1;
  repi(i,2,MAX+1){
    rep(j,3)if(i%s[j] == 0){
      chmax(dp[i], dp[i/s[j]]);
    }
  }
  rrep(i,MAX)dp[i] += dp[i-1];
  while(1){
    int l, r;
    scanf("%lld", &l);
    if(l == 0)break;
    scanf("%lld", &r);
    printf("%lld\n", dp[r]-dp[l-1]);
  }
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 11040
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


const int MAX = 1000000;
int dp[MAX+1], s[3] = {2, 3, 5};
signed main(){
  dp[1] = 1;
  repi(i,2,MAX+1){
    rep(j,3)if(i%s[j] == 0){
      chmax(dp[i], dp[i/s[j]]);
    }
  }
  rrep(i,MAX)dp[i] += dp[i-1];
  while(1){
    int l, r;
    scanf("%lld", &l);
    if(l == 0)break;
    scanf("%lld", &r);
    printf("%lld\n", dp[r]-dp[l-1]);
  }
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 10940
final_rank: 15

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main(){
  int m;
  int n,a,cnt;
  m =0 , n=0, a=0, cnt =0;
  while(1){
    cin >> m;
    if(m == 0) break;
    cin >> n;
 
    for(int i=m;i<=n;i++){
      a = i;
      
      while(a % 2 ==0) a = a / 2;
      while(a % 3 ==0) a = a / 3;
      while(a % 5 ==0) a = a / 5;

      if(a == 1) cnt++;
    }


    cout << cnt << endl;
    cnt =0;

  }



}
accuracy: 1
time_ms: 10
memory_kb: 3072
final_rank: 7

code_snippet: #include<bits/stdc++.h>
using namespace std;

bool check(int n){
  while(n%2==0){
    n/=2;
  }
  while(n%3==0){
    n/=3;
  }
  while(n%5==0){
    n/=5;
  }
  if(n==1){
    return true;
  }else{
    return false;
  }
}

int main(){
  int m,n;
  while(1){
    cin>>m;
    if(m==0)break;
    cin>>n;
    int ans=0;
    for(int i=m;i<=n;i++){
      if( check(i) ){
        ans++;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3092
final_rank: 9