Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- bool PotenzaDue(int);
- int main() {
- int N, x, numdec = 0;
- cin >> N;
- while(N != 0) {
- cin >> x;
- numdec += x * pow(2, N-1);
- N--;
- }
- cout << numdec << " ";
- if(PotenzaDue(numdec))
- cout << "SI";
- else
- cout << "NO";
- return 0;
- }
- bool PotenzaDue(int x) {
- for(int i = 1; i <= x; i *= 2) {
- if(i == x)
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement