Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created September 16, 2017 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save invatainfo/bdd0a51159b8aeb6a87fe1c20adfc227 to your computer and use it in GitHub Desktop.
Save invatainfo/bdd0a51159b8aeb6a87fe1c20adfc227 to your computer and use it in GitHub Desktop.
#include <iostream.h>
long sub(long n) {
if (n <= 5)
return n;
else {
long k = 5;
while (k <= n)
k = k * 2;
return k / 2;
}
}
void main() {
long s;
cin >> s;
while (s) {
long n = sub(s);
cout << n << " ";
s = s - n;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment