FARMAAN_KHANN's blog

By FARMAAN_KHANN, history, 21 month(s) ago, In English
#include <iostream>
using namespace std;
bool solve1(long long small,long long  big){
  int s=0;
  while(small>0){
    s+=small%10;
    small/=10;
  }
  int k = 0;
  while(big>0){
    k+=big%10;
    big/=10;
  }
  // cout<<s<<" "<<k<<'\n';
  if(s==k){
    return true;
  }else return false;
}
void solve(){
  long long  n; cin>>n;
  for(long long  i=1;i<n;i++){
    cout<<i<<'\n';
    if(solve1(i,n-i)){
      // cout<<'\n';
      cout<<i<<" "<<n-i<<'\n';
      return;
    }
  }
}
int main() 
{
    int t; cin>>t;
    while(t--){
      solve();
    }
}
  • Vote: I like it
  • -7
  • Vote: I do not like it

| Write comment?