Last active
November 2, 2016 12:10
-
-
Save aadimator/2293716b7b328cfb9ccd1ccdf7ae7d9d to your computer and use it in GitHub Desktop.
Find Digits - https://www.hackerrank.com/challenges/find-digits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(){ | |
int t; | |
cin >> t; | |
for(int a0 = 0; a0 < t; a0++){ | |
int n; | |
cin >> n; | |
int count = 0; | |
int quotient = n; | |
int remainder = quotient%10; | |
while (quotient > 9) { | |
if (remainder != 0 && n%remainder == 0) ++count; | |
quotient /= 10; | |
remainder = quotient%10; | |
} | |
if (quotient != 0 && n%quotient == 0) ++count; | |
cout << count << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment