Advertisement
Guest User

Untitled

a guest
May 5th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. // summ1m1_gl.pp Гордеева ЛН, 221, 10-09-2015
  2. // Пример программки красивого суммирования
  3. // денежных расходов :-)
  4. // Добавлен контроль ввода значений, вывод
  5. // даты и времени вычислений.
  6.  
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11.  
  12. namespace summ2m1_gl {
  13.  
  14. class Program {
  15.  
  16. static void Main(string[] args) {
  17. int n = Convert.ToInt32(Console.ReadLine());
  18. //Console.WriteLine(n);
  19. double[] tchk = new double[n + 1];
  20. for (int i = 1; i<=n; i++)
  21. {
  22. tchk[i] = Convert.ToDouble(Console.ReadLine());
  23. }
  24. double eps = 0.01;
  25. int x = 19;
  26. int a = 3125*25;
  27. int mod = 6679881;
  28. int b = 3145;
  29. double summ = 0;
  30. int vektor = 0;
  31. double[] y = new double[n + 1];
  32. // for (int k = 1; k <= 5; k++)
  33. for (int i = 1; i <= 1000000000; i++)
  34. {
  35. x = x * a + b;
  36. x = x % mod;
  37. if (x < 0) x = -x;
  38. //Console.WriteLine((double)(x) / (mod));
  39. y[i % n] = (double)(x) / (mod);
  40. if (i % n == 0)
  41. {
  42. y[n] = (double)(x) / (mod);
  43. for (int j1 = 1; j1 <= n; j1++)
  44. {
  45. summ = summ + (tchk[j1] - y[j1]) * (tchk[j1] - y[j1]);
  46. //Console.Write(y[j1]);
  47. //Console.Write(" ");
  48. }
  49. // Console.WriteLine(summ);
  50. }
  51. //Console.WriteLine();
  52. if ((summ > 0) & (summ < eps))
  53. {
  54. vektor = vektor + 1;
  55. // Console.WriteLine(y[1]);
  56. }
  57. summ = 0;
  58.  
  59. }
  60. Console.WriteLine(vektor);
  61. Console.ReadLine();
  62. }
  63.  
  64. }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement