Chef and Steps | Codechef
In order to establish dominance amongst his friends, Chef has decided that he will only walk in large steps of length exactly feet. However, this has presented many problems in Chef’s life because there are certain distances that he cannot traverse. Eg. If his step length is feet, he cannot travel a distance of feet. Chef has a strict travel plan that he follows on most days, but now he is worried that some of those distances may become impossible to travel. Given distances, tell Chef which ones he cannot travel.
Input:
- The first line will contain a single integer , the number of test cases.
- The first line of each test case will contain two space-separated integers - , the number of distances, and , Chef’s step length.
- The second line of each test case will contain space-separated integers, the of which represents , the distance of the path.
Output:
For each test case, output a string consisting of characters. The character should be if the distance is traversable, and if not.
Constraints
Subtasks
- 100 points: No additional constraints.
Sample Input:
1
5 3
12 13 18 20 27216
Sample Output:
10101
Solution(C++):
#include
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n,k;
cin>>n>>k;
vectorv;
while(n--)
{
int x;
cin>>x;
if(x%k==0)
v.push_back(1);
else
v.push_back(0);
}
for(auto i:v)
cout<
cout<
}
return 0;
}
Comments
Post a Comment