text: Check if N can be obtained from 1 by repetitively multiplying by 10 or 20 | C ++ program to check if N can be obtained from 1 by repetitive multiplication by 10 or 20 ; Function to check if N can be obtained or not ; Count and remove trailing zeroes ; Check if remaining N is a power of 2 ; To check the condition to print YES or NO ; Driver code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; void Is_possible ( long long int N ) { int C = 0 ; int D = 0 ; while ( N % 10 == 0 ) { N = N / 10 ; C += 1 ; } if ( pow ( 2 , ( int ) log2 ( N ) ) == N ) { D = ( int ) log2 ( N ) ; if ( C >= D ) cout << " YES " ; else cout << " NO " ; } else cout << " NO " ; } int main ( ) { long long int N = 2000000000000 ; Is_possible ( N ) ; }