|
|
back to boardtime limit exceeded #include <iostream> using namespace std; bool isOne(int n); int main(int argc, const char * argv[]) { int n; cin >> n;
int *nums = new int[n]; for (int i = 0; i < n; i++) { int k; cin >> k; nums[i] = k; } for (int i = 0; i < n; i++) { int index = nums[i] - 1; if (isOne(index)) cout << 1 << " "; else cout << 0 << " "; } delete [] nums; } bool isOne(int n) { int indexOf1 = 0; for (int i = 0; indexOf1 < n; i++) { indexOf1 += i; if (indexOf1 == n) return true; } return false;
} Edited by author 26.01.2014 16:27 |
|
|