Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

HackerEarth Special numbers problem solution

YASH PAL, 31 July 2024
In this HackerEarth Special numbers problem solution, A natural number is special if it consists of only digits 4 and 7. Find the number of pairs of сoprime special numbers (x, y) such that 1 <= x <= y <= N.
HackerEarth Special numbers problem solution

HackerEarth Special numbers problem solution.

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

int n;
vector<int> g;

void f(long long v) {
if (v > n) return;
if (v > 0) g.push_back(v);
f(10*v + 4);
f(10*v + 7);
}

int main() {
cin >> n;
f(0);
int result = 0;
for (int i = 0; i < (int)g.size(); ++i)
for (int j = i + 1; j < (int)g.size(); ++j)
if (__gcd(g[i], g[j]) == 1)
++result;
cout << result << 'n';
return 0;
}
coding problems solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes