https://www.codechef.com/practice/course/2to3stars/LP2TO301/problems/MAKEDIV3?tab=statement

intuition: how i this wrong i am not understanding, logic : all the multiples of 9 have the sum of each digit as multiple of 9: 9, 18 = 9, 27 = 19, 99 = 18, 9*1342575 = 12083175 = 27
my code:
void solve()
{
int n;
cin>>n;
string ans = “”;

int sm = 0;
while(n--)

{
ans += ‘3’;
sm += 3;
}
if(sm%9 == 0)
{
ans.pop_back();
ans += ‘0’;
}
cout<<ans<<endl;
}

Here is the code mate:-
The intuition is if number of digits is divisible by 3 then the number is divisible by 9.
Eg 333.

Code

include
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–){
int n;
cin>>n;
if(n%3 == 0){
while(n>1){
cout<<3;
n–;
}
cout<<9<<endl;
}
else{
while(n–){
cout<<3;
}
cout<<endl;
}
}
return 0;
}