1. "Традиционный" вариант //PascalABC.Net 3.0, сборка 1052 function NOD(a, b: longint): longint; begin while a <> b do if a > b then a := a - b else b := b - a; NOD := a end;
var f: Text; tNOD: longint;
begin Assign(f, 'input.txt'); Reset(f); if not Eof(f) then Readln(f, tNOD); var n: longint := 1; while (not Eof(f)) and (n > 0) and (tNOD > 1) do begin Readln(f, n); if n <> 0 then tNOD := NOD(tNOD, n) end; Close(f); Assign(f, 'output.txt'); Rewrite(f); Writeln(f,tNOD); Close(f) end.
2. "Современный" вариант //PascalABC.Net 3.0, сборка 1052 function NOD(a, b: integer): integer; begin while a <> b do if a > b then a -= b else b -= a; Result := a end;
var tNOD: integer := 0; n: integer;
begin foreach var sn in Readlines('input.txt') do begin n := StrToInt(sn); if tNOD = 0 then tNOD := n else if n = 0 then break else tNOD := NOD(tNOD, n); end; WriteAllText('output.txt', IntToSTR(tNOD)); end.
Пример файла input.txt находится во вложении, контрольный результат 4096
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cstring>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>typedef unsigned long long ulol;
typedef long double ld;
typedef long long lol;
typedef long int li;#define mp make_pair
#define F first
#define S second
#define sqr(a) ( (a) * (a) )
#define pb push_back
#define INF 999999999
#define ret(a) cout << endl; system("pause"); return(a)
//#define ret(a) return(a)using namespace std;int main()
{
ld x;
cin >> x;
x = ( 8 / sqrt( x ) ) + sqrt(x);
cout << x;
ret(0);
}