Cod sursa(job #2791447)
Utilizator | Data | 30 octombrie 2021 15:22:30 | |
---|---|---|---|
Problema | Litere | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin("n311.in");
ofstream cout("n311.out");
int n,i;
int main() {
cin>>n;
while (n>1) {
if (n/3==1) {
cout<<"1"<<" "<<"1";
}
else {
if (n%3==0) {
n/=3;
cout<<"3"<<" ";
}
else {
if (n%3==2) {
n+=1;
cout<<"1"<<" ";
}
else {
if (n%3==1) {
n-=1;
cout<<"-1"<<" ";
}
}
}
}
}
}