GeeksforGeeks Solution For School Domain .Below You Can Find The Solution Of Basic ,Easy ,Medium ,Hard .You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers
Problem :- Two friends are playing a game. One gives an integer N to other and asks: What is the number of divisors of N that are divisible by 3? The task is to help the other friend in finding the number of divisors.
Input:
The first line of input contains an integer T denoting the number of test cases.Then T test cases follow .Each test case consist of an integer N.
Output:
For each test case in a new line print the number of divisors.
Submit Your Solution :- Click Here
Solution :-
#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n,i,count=0;
cin>>n;
for(i=1;i<=n;i++)
{
if(n%i==0)
{
if(i%3==0)
{
count++;
}
}
}
cout<<count<<endl;
}
return 0;
}
Output:-
0 Comments: