Edited by author 01.02.2017 17:12 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. 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. > 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. #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; } } 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. What is the use of showing you and your code off ? Instead of getting proud of yourself, giving clarification is much more better Instead of getting proud of yourself and giving right code, giving clarification is much more better Thanks to author! Edited by author 19.11.2014 21:49 Absolutely right, Grant! I entirely agree with you. Right!!! Easy when you understand it. It took me the monthes to understand how stupid this problem is. I wanted do this problem with brute force, by recursion, a lot of different ways, until I understood. Any way, this problem is really stupid.)) i solved it but still didn't get what the problem is "Brainbreaking text, brainless task" - exactly It took me 20 minutes to solve it.)) (the hardest part is to read the text and to write the code). )) This problem doesn't help improving any algorithm but it improves your mind to translate your understanding to easy code. (I think) Edited by author 23.01.2014 19:53 I have WA 1 but on my computer all ok. Is first test not like in statement? what i have to do ?!! P( i<1> , i<2> , i<3> , ... , i<n-1> , i<n> ) determines at which position is the X[ i<1> , i<2> , i<3> , ... , i<n-1> , i<n> ] element in ( lets say ) RAM . And the Function P is absolutely correct. You should determine the dimensions k<1> , k<2> , k<3> , ... , k<n-1> , k<n> of the X for the given D elements. I don't know whether I could explain it, if not I'm really sorry ! I can't do much. :( Edited by author 16.10.2012 23:40 Edited by author 16.10.2012 23:39 import java.util.Scanner; public class T1228 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] a = new int[n+1]; for (int i = 1; i <=n; i++) { a[i] = in.nextInt(); } k -=1; int t=1; while (k!=0) { System.out.print((k/a[t])+" "); k = k%a[t]; t++; } } } Edited by author 12.01.2008 04:09 Edited by author 12.01.2008 04:10 Edited by author 12.01.2008 04:10 var n, s, p, i: longint; d, k: array[1..21]of longint; begin readln(n, s); for i:=1 to n do readln(d[i]); k[n]:=d[n-1]; p:=k[n]; for i:=n-1 downto 2 do begin k[i]:=d[i-1] div p; p:=p*k[i]; end; k[1]:=s div p; for i:=1 to n-1 do write(k[i]-1, ' '); writeln(k[n]-1); end. Yes. It follows from the task statement. find all K such that 1+ sumof (Di*Ki) i=1->N = S ? |
|