My issue
include <bits/stdc++.h>
using namespace std;
int main()
{
int ti, n;
cin >> ti;
while (ti–)
{
unordered_map<long, long> m; // val req,rev val
int c = 0;
cin >> n;
while (n–)
{
long long t;
cin >> t;
long long f = t / (t - 3);
m[f] = 1;
if (m.find(t) != m.end())
{
c++;
}
}
cout<<c<<endl;
}
return 0;
}
why this code is giving runtime error
My code
#include <bits/stdc++.h>
using namespace std;
int main()
{
int ti, n;
cin >> ti;
while (ti--)
{
unordered_map<long, long> m; // val req,rev val
int c = 0;
cin >> n;
while (n--)
{
long long t;
cin >> t;
long long f = t / (t - 3);
m[f] = 1;
if (m.find(t) != m.end())
{
c++;
}
}
cout<<c<<endl;
}
return 0;
}
Problem Link: Freedom Practice Coding Problem - CodeChef