Language: C++

#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;

double z;
long w;
long zmax=0;
long start;
int result[100]={};
bool find =false;
string S;
//3/11;

int main(){
	scanf("%ld",&w);
	z=(double)w;
	while(z>=3){
		z/=3;
		zmax++;
	}

	S+="+";
	switch(zmax){

			case 0:
											for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																S+="+";
															}
														}
														
														break;
													}
												}
	break;

			case 1:
											for(int l=-1;l<2;l++){
												result[1]=l;
												for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m+l*3+9){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																S+="+";
															}
														}
														
														break;
													}
												}
												if(find== true){
													break;
												}
											}
	break;

			case 2: 
										for(int k=-1;k<2;k++){
											result[2]=k;
											for(int l=-1;l<2;l++){
												result[1]=l;
												for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m+l*3+k*9+27){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																S+="+";
															}
														}
														break;
													}
												}
												if(find== true){
													break;
												}
											}
											if(find== true){
													break;
												}
										}
	break;

			case 3: 
									for(int j=-1;j<2;j++){
										result[3]=j;
										for(int k=-1;k<2;k++){
											result[2]=k;
											for(int l=-1;l<2;l++){
												result[1]=l;
												for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m+l*3+k*9+j*27+81){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																S+="+";
															}
														}
														
														break;
													}
												}
												if(find== true){
													break;
												}
											}
											if(find== true){
													break;
												}
										}
										if(find== true){
													break;
												}
									}
	break;
			case 4:
								for(int h=-1;h<2;h++){
									result[4]=h;
									for(int j=-1;j<2;j++){
										result[3]=j;
										for(int k=-1;k<2;k++){
											result[2]=k;
											for(int l=-1;l<2;l++){
												result[1]=l;
												for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m+l*3+k*9+j*27+h*81+243){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																
															}
														}
														
														break;
													}
												}
												if(find== true){
													break;
												}
											}
											if(find== true){
													break;
												}
										}
										if(find== true){
													break;
												}
									}
									if(find== true){
													break;
												}
								}
	break;


			case 5: 
							for(int g=-1;g<2;g++){
								result[5]=g;
								for(int h=-1;h<2;h++){
									result[4]=h;
									for(int j=-1;j<2;j++){
										result[3]=j;
										for(int k=-1;k<2;k++){
											result[2]=k;
											for(int l=-1;l<2;l++){
												result[1]=l;
												for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m+l*3+k*9+j*27+h*81+g*243+729){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																S+="+";
															}
														}
														
														break;
													}
												}
												if(find== true){
													break;
												}
											}
											if(find== true){
													break;
												}
										}
										if(find== true){
													break;
												}
									}
									if(find== true){
													break;
												}
								}
								if(find== true){
													break;
												}
							}
	break;

		case 6: 
						for(int f=-1;f<2;f++){
							result[6]=f;
							for(int g=-1;g<2;g++){
								result[5]=g;
								for(int h=-1;h<2;h++){
									result[4]=h;
									for(int j=-1;j<2;j++){
										result[3]=j;
										for(int k=-1;k<2;k++){
											result[2]=k;
											for(int l=-1;l<2;l++){
												result[1]=l;
												for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m+l*3+k*9+j*27+h*81+g*243+f*729+2187){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																S+="+";
															}
														}
														
														break;
													}
												}
												if(find== true){
													break;
												}
											}
											if(find== true){
													break;
												}
										}
										if(find== true){
													break;
												}
									}
									if(find== true){
													break;
												}
								}
								if(find== true){
													break;
												}
							}
							if(find== true){
													break;
												}
						}
	break;

		case 7: 
					for(int e=-1;e<2;e++){
						result[7]=e;
						for(int f=-1;f<2;f++){
							result[6]=f;
							for(int g=-1;g<2;g++){
								result[5]=g;
								for(int h=-1;h<2;h++){
									result[4]=h;
									for(int j=-1;j<2;j++){
										result[3]=j;
										for(int k=-1;k<2;k++){
											result[2]=k;
											for(int l=-1;l<2;l++){
												result[1]=l;
												for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m+l*3+k*9+j*27+h*81+g*243+f*729+e*2187+6561){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																S+="+";
															}
														}
														
														break;
													}
												}
												if(find== true){
													break;
												}
											}
											if(find== true){
													break;
												}
										}
										if(find== true){
													break;
												}
									}
									if(find== true){
													break;
												}
								}
								if(find== true){
													break;
												}
							}
							if(find== true){
													break;
												}
						}
						if(find== true){
													break;
												}
					}
	break;

		case 8: 
				for(int d=-1;d<2;d++){
					result[8]=d;
					for(int e=-1;e<2;e++){
						result[7]=e;
						for(int f=-1;f<2;f++){
							result[6]=f;
							for(int g=-1;g<2;g++){
								result[5]=g;
								for(int h=-1;h<2;h++){
									result[4]=h;
									for(int j=-1;j<2;j++){
										result[3]=j;
										for(int k=-1;k<2;k++){
											result[2]=k;
											for(int l=-1;l<2;l++){
												result[1]=l;
												for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m+l*3+k*9+j*27+h*81+g*243+f*729+e*2187+d*6561+19683){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																S+="+";
															}
														}
														
														break;
													}
												}
												if(find== true){
													break;
												}
											}
											if(find== true){
													break;
												}
										}
										if(find== true){
													break;
												}
									}
									if(find== true){
													break;
												}
								}
								if(find== true){
													break;
												}
							}
							if(find== true){
													break;
												}
						}
						if(find== true){
													break;
												}
					}
					if(find== true){
											break;
										}
			}
	break;

		case 9: 
			for(int c=-1;c<2;c++){	
				result[9]=c;
				for(int d=-1;d<2;d++){
					result[8]=d;
					for(int e=-1;e<2;e++){
						result[7]=e;
						for(int f=-1;f<2;f++){
							result[6]=f;
							for(int g=-1;g<2;g++){
								result[5]=g;
								for(int h=-1;h<2;h++){
									result[4]=h;
									for(int j=-1;j<2;j++){
										result[3]=j;
										for(int k=-1;k<2;k++){
											result[2]=k;
											for(int l=-1;l<2;l++){
												result[1]=l;
												for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m+l*3+k*9+j*27+h*81+g*243+f*729+e*2187+d*6561+c*19683+59049){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																S+="+";
															}
														}
														
														break;
													}
												}
												if(find== true){
													break;
												}
											}
											if(find== true){
													break;
												}
										}
										if(find== true){
													break;
												}
									}
									if(find== true){
													break;
												}
								}
								if(find== true){
													break;
												}
							}
							if(find== true){
													break;
												}
						}
						if(find== true){
													break;
												}
					}
					if(find== true){
											break;
										}
			}
				if(find== true){
											break;
										}
			}
	break;


case 10: 
		for(int b=-1;b<2;b++){
			result[10]=b;
			for(int c=-1;c<2;c++){	
				result[9]=c;
				for(int d=-1;d<2;d++){
					result[8]=d;
					for(int e=-1;e<2;e++){
						result[7]=e;
						for(int f=-1;f<2;f++){
							result[6]=f;
							for(int g=-1;g<2;g++){
								result[5]=g;
								for(int h=-1;h<2;h++){
									result[4]=h;
									for(int j=-1;j<2;j++){
										result[3]=j;
										for(int k=-1;k<2;k++){
											result[2]=k;
											for(int l=-1;l<2;l++){
												result[1]=l;
												for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m+l*3+k*9+j*27+h*81+g*243+f*729+e*2187+d*6561+c*19683+b*59049+177147){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																S+="+";
															}
														}
														
														break;
													}
												}
												if(find== true){
													break;
												}
											}
											if(find== true){
													break;
												}
										}
										if(find== true){
													break;
												}
									}
									if(find== true){
													break;
												}
								}
								if(find== true){
													break;
												}
							}
							if(find== true){
													break;
												}
						}
						if(find== true){
													break;
												}
					}
					if(find== true){
													break;
												}
				}
				if(find== true){
													break;
												}
			}
			if(find== true){
													break;
												}
		}
	break;


	case 11: 
for(int a=-1;a<2;a++){
	result[11]=a;
		for(int b=-1;b<2;b++){
			result[10]=b;
			for(int c=-1;c<2;c++){	
				result[9]=c;
				for(int d=-1;d<2;d++){
					result[8]=d;
					for(int e=-1;e<2;e++){
						result[7]=e;
						for(int f=-1;f<2;f++){
							result[6]=f;
							for(int g=-1;g<2;g++){
								result[5]=g;
								for(int h=-1;h<2;h++){
									result[4]=h;
									for(int j=-1;j<2;j++){
										result[3]=j;
										for(int k=-1;k<2;k++){
											result[2]=k;
											for(int l=-1;l<2;l++){
												result[1]=l;
												for(int m=-1;m<2;m++){
													result[0]=m;
													if(w==m+l*3+k*9+j*27+h*81+g*243+f*729+e*2187+d*6561+c*19683+b*59049+a*177147+531441){
														find =true;
														for(int i=zmax;i>=0;i--){
															if(result[i]==-1){
																S+="-";
															}
															if(result[i]==0){
																S+="0";
															}
															if(result[i]==1){
																S+="+";
															}
														}
														
														break;
													}
												}
												if(find== true){
													break;
												}
											}
											if(find== true){
													break;
												}
										}
										if(find== true){
													break;
												}
									}
									if(find== true){
													break;
												}
								}
								if(find== true){
													break;
												}
							}
							if(find== true){
													break;
												}
						}
						if(find== true){
													break;
												}
					}
					if(find== true){
													break;
												}
				}
				if(find== true){
													break;
												}
			}
			if(find== true){
													break;
												}
		}
		if(find== true){
												break;
											}
	}
	break;
}

if(w==1){
	S="+";
}
if(w==2){
	S="+-";
}

		cout<<S<<endl;

	return 0;
}

Compiler output:
a.cc:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
a.cc: In function 'int main()':
a.cc:31:113: error: reference to 'find' is ambiguous
   31 |                                                                                                                 find =true;
      |                                                                                                                 ^~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:4:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:55:113: error: reference to 'find' is ambiguous
   55 |                                                                                                                 find =true;
      |                                                                                                                 ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:71:100: error: reference to 'find' is ambiguous
   71 |                                                                                                 if(find== true){
      |                                                                                                    ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:85:113: error: reference to 'find' is ambiguous
   85 |                                                                                                                 find =true;
      |                                                                                                                 ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:100:100: error: reference to 'find' is ambiguous
  100 |                                                                                                 if(find== true){
      |                                                                                                    ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:104:92: error: reference to 'find' is ambiguous
  104 |                                                                                         if(find== true){
      |                                                                                            ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:120:113: error: reference to 'find' is ambiguous
  120 |                                                                                                                 find =true;
      |                                                                                                                 ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:136:100: error: reference to 'find' is ambiguous
  136 |                                                                                                 if(find== true){
      |                                                                                                    ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:140:92: error: reference to 'find' is ambiguous
  140 |                                                                                         if(find== true){
      |                                                                                            ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:144:84: error: reference to 'find' is ambiguous
  144 |                                                                                 if(find== true){
      |                                                                                    ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:161:113: error: reference to 'find' is ambiguous
  161 |                                                                                                                 find =true;
      |                                                                                                                 ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:177:100: error: reference to 'find' is ambiguous
  177 |                                                                                                 if(find== true){
      |                                                                                                    ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:181:92: error: reference to 'find' is ambiguous
  181 |                                                                                         if(find== true){
      |                                                                                            ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidates are: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
a.cc:12:6: note:                 'bool find'
   12 | bool find =false;
      |      ^~~~
a.cc:185:84: error: reference to 'find' is ambiguous
  185 |