fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Threading;
  5. using System.Diagnostics;
  6.  
  7. namespace A
  8. {
  9. class Program
  10. {
  11. private const int N = 1000000;
  12.  
  13. private static void Main(string[] args)
  14. {
  15. long trash = 0;
  16. const int a1 = 0, a2 = 1, b = 1;
  17. var result0 = 0.0;
  18. var result1 = 0.0;
  19. for (int i = 0; i < N; i++)
  20. {
  21. var sw = Stopwatch.StartNew();
  22. int c = a1 == 0 ? b : a1;
  23. int d = a2 == 0 ? b : a2;
  24. sw.Stop();
  25. trash += c + d;
  26. result0 += (double)sw.ElapsedTicks;
  27.  
  28. var sw2 = Stopwatch.StartNew();
  29. c = a1 - a1 * a1 * b + b;
  30. d = a2 - a2 * a2 * b + b;
  31. sw2.Stop();
  32. trash += c + d;
  33. result1 += (double)sw2.ElapsedTicks;
  34. }
  35. Console.WriteLine(trash);
  36. Console.WriteLine("res1 = {0}", result0/N);
  37. Console.WriteLine("res2 = {0}", result1/N);
  38.  
  39. } // your code goes here
  40. }
  41. }
Success #stdin #stdout 1.25s 33904KB
stdin
Standard input is empty
stdout
4000000
res1 = 2.509905
res2 = 2.506366