Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int tests, squared, sumofDigits;
- int digit = 0;
- int base = 2;
- int array[3];
- cin >> tests;
- if (1 <= tests && tests <= 100)
- {
- for (int i = 0; i < tests; i++)
- {
- cin >> digit;
- if (1 <= digit && digit <= 10000)
- {
- int square = pow(base,digit);
- squared = square;
- for (int i = 2; i >= 0; i--)
- {
- array[i] = squared % 10;
- squared /= 10;
- }
- sumofDigits = array[0] + array[1] + array[2];
- cout << sumofDigits << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement