fork download
  1. ' vbc /optimize /optionexplicit /optionstrict pftest5.vb
  2.  
  3. Imports System
  4.  
  5. Module pftest5
  6. Sub Test()
  7. Const MAXDIM As Integer = 30000
  8. Dim sum As Double = 0.0
  9. Dim rdm As New Random()
  10.  
  11. Dim dm(MAXDIM-1) As Double
  12.  
  13. Dim i As Integer, j As Integer
  14. Dim temp As Double
  15.  
  16. For i = 0 To MAXDIM-1
  17. dm(i) = rdm.NextDouble()
  18. Next
  19.  
  20. Dim tstart As Integer = System.Environment.TickCount
  21.  
  22. For i = 0 To MAXDIM-1
  23. j = MAXDIM - i - 1
  24. dm(i) = dm(i) * dm(j) + 1
  25. Next
  26.  
  27. For i = 0 To MAXDIM-1
  28. j = MAXDIM - 1
  29. Do While j > i
  30. If dm(i) > dm(j) Then
  31. temp = dm(i)
  32. dm(i) = dm(j)
  33. dm(j) = temp
  34. End If
  35. j = j - 1
  36. Loop
  37. Next
  38.  
  39. For i = 0 To MAXDIM-1
  40. j = MAXDIM - i - 1
  41. dm(i) = dm(i) * dm(j) - 1
  42. Next
  43.  
  44. For i = 0 To MAXDIM-1
  45. sum = sum + dm(i)
  46. Next
  47.  
  48. Dim tend As Integer = System.Environment.TickCount
  49.  
  50. Console.WriteLine("SUM = {0} : elpased = {1}", sum, tend - tstart)
  51. End Sub
  52.  
  53. Sub Main()
  54. Dim i As Integer
  55. Console.WriteLine("VB.NET")
  56. For i = 1 To 10
  57. Test()
  58. Next
  59. End Sub
  60. End Module
  61.  
Time limit exceeded #stdin #stdout 5s 16776KB
stdin
Standard input is empty
stdout
VB.NET
SUM = 27830.4825312899 : elpased = 3067