Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.87 KB | None | 0 0
  1. program Project2;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7.  
  8. var n,i,j,k,sum,sum2,x,l:integer;
  9. a,b:array[1..100000] of integer;
  10. c:array[1..6] of integer;
  11.  
  12. begin
  13.   reset(Input,'1.txt');
  14.   rewrite(output,'2.txt');
  15.   c[1]:=10; c[2]:=50;c[3]:=100;c[4]:=500;c[5]:=1000;c[6]:=5000;
  16.   read(a[1],a[2],a[3],a[4],a[5],a[6],n);
  17.   k:=0;
  18.   sum:=10*a[1]+50*a[2]+100*a[3]+500*a[4]+1000*a[5]+5000*a[6];
  19.   if a[1]<>0 then k:=1 else if a[2]<>0 then k:=2 else if a[3]<>0 then k:=3 else if a[4]<>0 then k:=4 else if a[5]<>0 then k:=5 else if a[6]<>0 then k:=6;
  20.   sum2:=sum-c[k];
  21.   i:=0;
  22.   if k=0 then begin
  23.     write(0);
  24.     halt;
  25.  
  26.   end;
  27.   while sum>sum2 do begin
  28.     k:=sum div n;
  29.     if k<>c[x] then begin
  30.       inc(x);
  31.       c[x]:=k;
  32.     end;
  33.     dec(sum,10);
  34.   end;
  35.   writeln(x);
  36.   for i:=x downto 1 do begin
  37.   if c[i]=0 then continue;
  38.   write(c[i],' ');
  39.  
  40.   end;
  41.  
  42.  
  43.  
  44. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement