// UVa 11185 - Ternary
#include <iostream>
#include <string>
using namespace std;
#define datatype signed long long int
int main() {
datatype n;
cin >> n;
while (n >= 0) {
string sol = "";
while (n) {
sol = ((char) ((n % 3) + '0')) + sol;
n /= 3;
}
if (sol.length() == 0)
sol = "0";
cout << sol << endl;
cin >> n;
}
return 0;
}
No comments:
Post a Comment