|
|
вернуться в форумMy Solution Here: program arrays; var k:array[1..20]of longint; d:array[0..20]of longint; n:integer; s:longint; procedure init; var i:integer; begin readln(n,s); for i:=1 to n do readln(d[i]); d[0]:=s; end; procedure solve; var i:integer; begin k[n]:=d[n-1]-1; for i:=n-1 downto 1 do k[i]:=(d[i-1] div d[i])-1; for i:=1 to n-1 do write(k[i],' '); writeln(k[n]); end; begin init; solve; end. mine???shorter const maxn=20; var w,n,i:longint; a,b:array [1..maxn] of longint; begin readln(w,n); for i:=1 to w do readln(a[i]); n:=n-1;i:=1; repeat b[i]:=n div a[i]; n:=n mod a[i]; inc(i); until n=0; for i:=1 to w do write(b[i],' '); end. there are something i feel wrong but hard to say though i got AC my program is wrong.but i don't know why it got AC...??? > const maxn=20; > var w,n,i:longint; > a,b:array [1..maxn] of longint; > begin > readln(w,n); > for i:=1 to w do readln(a[i]); > n:=n-1;i:=1; > repeat > b[i]:=n div a[i]; > n:=n mod a[i]; > inc(i); > until n=0; > for i:=1 to w do write(b[i],' '); > end. what about mine? #include <fstream.h> void main() { int n, s, t, i; cin >> n >> s; for(i=0; i<n; i++) { cin >> t; cout << (s / t) - 1 << " "; s = t; } } Shoter and shoter Послано Oyh 11 мар 2009 10:42 var n,s,d:longint; begin readln(n,s); dec(s); for n:=1 to n do begin readln(d); write(s div d,' '); s:=s mod d; end; end. Re: Shoter and shoter Послано Abbos 31 июл 2016 12:15 What is the use of showing you and your code off ? Re: My Solution Here: Послано Abbos 31 июл 2016 12:17 Instead of getting proud of yourself, giving clarification is much more better Re: My Solution Here: Послано Abbos 31 июл 2016 12:18 Instead of getting proud of yourself and giving right code, giving clarification is much more better |
|
|