daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2.  
  3. using namespace std;
  4. ifstream cin("n311.in");
  5. ofstream cout("n311.out");
  6. int v[1001];
  7. int main()
  8. {
  9.     int n,i=0,c=0;
  10.     cin>>n;
  11.     while (n!=0)
  12.     switch (n%3)
  13.     {
  14.         case 0: n/=3; v[i]=3; c++; i++; break;
  15.         case 1: n-=1; v[i]=1; c++; i++; break;
  16.         case 2: n+=1; v[i]=-1; c++;i++;break;
  17.  
  18.     }
  19.     for (i=1;i<c;i++)
  20.         cout<<v[i]<<' ';
  21.     return 0;
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top