Cod sursa(job #1659125)

Utilizator mihaitamoglanmihai moglan mihaitamoglan Data 21 martie 2016 23:54:02
Problema Fractii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.17 kb
{
   Fractii.pas
   
   Copyright 2016 MihaiMoglan <mihaitamoglan@Private>
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
   MA 02110-1301, USA.
   
   
}

type tablou=array [1..1000000]of longint;

var t:tablou;
	i,j,m,n:qword;
	f,g:text;

BEGIN
	assign(f,'fractii.in');
	assign(g,'fractii.out');
	reset(f);
	rewrite(g);
	read(f,n);
	for i:=2 to n do
	 t[i]:=1;
	for i:=2 to (n div 2) do
	 for j:=1 to ((n div i)-1 ) do
	   t[i*(j+1)]:=t[i*(j+1)]+2*j;
	m:=0;
	for i:=1 to n do
	 m :=m+ n-t[i];
	write(g,m);
    close(f);
    close(g);
END.