title: Three Different Numbers
body: <p>I`m stuck on the problem below. My solution exceeds the time limit. Can someone give me an idea how to improve it?</p>
  
  <p>You just need to count the number of ordered triples of different numbers (X1, X2, X3), where Xi could be any positive integer from 1 to Ni, inclusive (i = 1, 2, 3).
  Numbers N1, N2, N3 could be up to 10^18.
  Because of this the answer could be quite large. Hence you should output it modulo 10^9 + 7.</p>
  
  <p>Input</p>
  
  <p>The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. The only line of each test case contains three space-separated integers N1, N2, N3.</p>
  
  <p>Output</p>
  
  <p>For each test case, output a single line containing the number of required triples modulo 10^9 + 7.</p>
  
  <p>Constraints</p>
  
  <p>1 ≤ T ≤ 1000</p>
  
  <p>1 ≤ Ni ≤ 10^18</p>
  
  <pre><code>Example
  
  Input:
  
  5
  
  3 3 3
  2 4 2
  1 2 3
  25 12 2012
  1 1 2013
  
  Output:
  6
  4
  1
  578880
  0
  </code></pre>
  
  <p>Here is my solution:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
  int t;
  scanf("%d",&amp;t);
  for(int i=0; i&lt;t; i++)
  {
      long long unsigned a,b,c,sum=0,s1,s2,s3;
      scanf("%llu %llu %llu", &amp;a,&amp;b,&amp;c);
      for(s1=1; s1&lt;=a; s1++)
      {
          for(s2=1; s2&lt;=b; s2++)
          {
              if(s1==s2) continue;
              for(s3=1; s3&lt;=c; s3++)
              {
                  if(s1==s3 || s2==s3) continue;
                  sum=(sum+1)%1000000007;
              }
          }
      }
      printf("%llu\n",sum);
  }
  return 0;
  }
  </code></pre>