Posts

Showing posts with the label counting pretty numbers

CodeChef::NUM239

  #include <bits/stdc++.h> using namespace std ; int main (){ int t ; cin >> t ; while (t--){ int left ; int right ; cin >> left >> right ; int full_array[right - left + 1 ] ; for ( int i = 0 ; i < right - left + 1 ; ++i) { full_array[i] = i + left ; } int count { 0 } ; for ( int i = 0 ; i < right - left + 1 ; ++i) { if (full_array[i] % 10 == 2 or full_array[i] % 10 == 3 or full_array[i] % 10 == 9 ){ count ++ ; } } cout << count << ' \n ' ; } return 0 ; }