Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // summ1m1_gl.pp Гордеева ЛН, 221, 10-09-2015
- // Пример программки красивого суммирования
- // денежных расходов :-)
- // Добавлен контроль ввода значений, вывод
- // даты и времени вычислений.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace summ2m1_gl {
- class Program {
- static void Main(string[] args) {
- int n = Convert.ToInt32(Console.ReadLine());
- //Console.WriteLine(n);
- double[] tchk = new double[n + 1];
- for (int i = 1; i<=n; i++)
- {
- tchk[i] = Convert.ToDouble(Console.ReadLine());
- }
- double eps = 0.01;
- int x = 19;
- int a = 3125*25;
- int mod = 6679881;
- int b = 3145;
- double summ = 0;
- int vektor = 0;
- double[] y = new double[n + 1];
- // for (int k = 1; k <= 5; k++)
- for (int i = 1; i <= 1000000000; i++)
- {
- x = x * a + b;
- x = x % mod;
- if (x < 0) x = -x;
- //Console.WriteLine((double)(x) / (mod));
- y[i % n] = (double)(x) / (mod);
- if (i % n == 0)
- {
- y[n] = (double)(x) / (mod);
- for (int j1 = 1; j1 <= n; j1++)
- {
- summ = summ + (tchk[j1] - y[j1]) * (tchk[j1] - y[j1]);
- //Console.Write(y[j1]);
- //Console.Write(" ");
- }
- // Console.WriteLine(summ);
- }
- //Console.WriteLine();
- if ((summ > 0) & (summ < eps))
- {
- vektor = vektor + 1;
- // Console.WriteLine(y[1]);
- }
- summ = 0;
- }
- Console.WriteLine(vektor);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement