记录编号 209032 评测结果 AAAAAAAAAA
题目名称 [USACO Nov07] 阅读大赛 最终得分 100
用户昵称 GravatarTwist Fate 是否通过 通过
代码语言 Pascal 运行时间 0.007 s
提交时间 2015-11-20 20:25:56 内存使用 0.18 MiB
显示代码纯文本
program yuedu;
var
	si1,ti1,ri1,ww:string;
	a,si,ti,ri:array[1..1000] of longint;
	k,i,n,j,bb,r,t:longint;
begin
	assign(input,'read.in');	reset(input);
	assign(output,'read.out');	rewrite(output);
	readln(n,k);
	i:=0;
	repeat
		i:=i+1;
		readln(ww);
		j:=pos(' ',ww);
		si1:=copy(ww,1,j-1);
		val(si1,si[i]);
		delete(ww,1,j);//
		j:=pos(' ',ww);
		ti1:=copy(ww,1,j-1);
		val(ti1,ti[i]);
		delete(ww,1,j);//
		ri1:=ww;
		val(ri1,ri[i]);
	until i=k;
	for i:=1 to k do 
		a[i]:=si[i]*ti[i];
	i:=0;
	repeat 
		j:=0;
		r:=0;
		t:=0;
		i:=i+1;
		j:=n div  a[i]; 
		if j=0 then begin
			if (n-j*a[i])mod si[i]>0 then 
			r:=(n-j*a[i])div si[i]+1;
			if (n-j*a[i]<>0) and ((n-j*a[i])mod si[i]=0) then 
			r:=(n-j*a[i])div si[i];
		end;
		if j>0 then  begin
			if (n-j*a[i])mod si[i]>0 then 
			r:=(n-j*a[i])div si[i]+1;
			if (n-j*a[i]<>0) and ((n-j*a[i])mod si[i]=0) then 
			r:=(n-j*a[i])div si[i];
		end;
		t:=j;
		if (n mod a[i]=0) then
			t:=t-1;
		a[i]:=t*ri[i]+r+ti[i]*j;
	until i=k;
	for i:=1 to k do 
		writeln(a[i]);
	close(input);	close(output);
end.