Pre - requisite:
STL (C++)Difficulty :
Easy
Problem statement:
We need to print the modulo 1007 of those numbers whose remainder value have not yet appeared.
Explanation:
we can use a map<long long int, long long int> m where the first index specifies the remainder value.
Initially the value of m[i] for all i is 0 by default. Whenever we encounter a number we check if m[n%1007] is equal to 0 or not. If it is zero print the value and increment m[n%1007].
Solution:
#include using namespace std; main() { long long int t,a,r; map m; scanf("%lld",&t); while(t--) { scanf("%lld",&a); r=a%1007; if(m[r]==0) { printf("%lld\n",r); m[r]++; } } return 0; }