title: how do i further reduce the run time of this code
body: <p>how do i reduce the run time of this code and bring it below 3 sec. a and b vary from 1        to 10^9 and testcases from 1 to 100</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  using namespace std;
  static int testCases;
  
  static int result[100];
  
  
  int main()
  {
    cin&gt;&gt;testCases;
    for (int i = 0; i &lt; testCases; i++) {
      int a, b;
      cin&gt;&gt;a;
      cin&gt;&gt;b;
      int count = 0;
      while (a &lt;= b) {
        double lim = sqrt(a);
        int special = 1;
        for (int z = 2; z &lt;= lim; z++) {
          if (a % (z * z) == 0) {
            special = 0;
            break;
          }
        }
        if (special == 1)
          count++;
  
        a++;
      }
      result[i]=count;
    }
    for (int i = 0; i &lt; testCases; i++)
      cout&lt;&lt;result[i]&lt;&lt;"\n";
  
  }
  </code></pre>