普及练习场之简单的模拟
2017-02-03 19:38
477 查看
前言:如标题所说。
P1003 铺地毯
总:look前言。
P1017 进制转换
总:同上。
总:同上,注意情况。
P1067 多项式输出
P1540 机器翻译
总:开个数组记录,然后…模拟。
P1056 排座椅
点击:排座椅题解
P1125 笨小猴
总:将字母大写化(小写化也行),用数组统计,暴力max and min,判断质数。
P1003 铺地毯
总:look前言。
var s,n,m,t,p:longint; a,b,x,y:array [1..10001] of longint; begin readln(s); for t:=1 to s do readln(a[t],b[t],x[t],y[t]); readln(n,m); p:=0; for t:=1 to s do if (n>=a[t]) and (n<=a[t]+x[t]) and (m>=b[t]) and (m<=b[t]+y[t]) then p:=t; if p=0 then write('-1') else write(p); end.
P1017 进制转换
总:同上。
const ss='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; var n,x,i,m:longint; s:string; begin readln(n,x); m:=n; s:=''; repeat i:=m mod x; m:=m div x; if i<0 then begin i:=i-x; m:=m+1; end; s:=ss[i+1]+s; until m=0; writeln(n,'=',s,'(base',x,')'); end.
总:同上,注意情况。
P1067 多项式输出
var n,s,i:longint; begin readln(n); for i:=1 to n+1 do begin read(s); if s=0 then continue; if s<0 then write('-'); if (i>1)and(s>0) then write('+'); if (abs(s)>1) or (i=n+1) then write(abs(s)); if i<n+1 then begin write('x'); if (i<n) then write('^',n-i+1); end; end; end.
P1540 机器翻译
总:开个数组记录,然后…模拟。
var q:array[0..10000]of longint; m,n,x,i,j:longint; head,tail,ans:longint; f:boolean; begin readln(m,n); head:=1; tail:=0; ans:=0; for i:=1 to n do begin read(x); f:=false; for j:=head to tail do if x=q[j] then begin f:=true; break end; if f then continue; inc(tail); q[tail]:=x; inc(ans); if ans>m then inc(head); end; write(ans); end.
P1056 排座椅
点击:排座椅题解
P1125 笨小猴
总:将字母大写化(小写化也行),用数组统计,暴力max and min,判断质数。
var s:string; l,i,j,max,min,k:longint; a:array ['A'..'Z'] of longint; t:char; f:boolean; begin readln(s); l:=length(s); for i:=1 to l do begin s[i]:=upcase(s[i]); inc(a[s[i]]); end; max:=0; min:=maxlongint; for t:='A' to 'Z' do begin if (max<a[t]) and (a[t]<>0) then max:=a[t]; if (min>a[t]) and (a[t]<>0) then min:=a[t]; end; k:=max-min; if k<=1 then begin writeln('No Answer'); write('0'); exit; end; f:=true; for i:=2 to trunc(sqrt(k)) do if k mod i=0 then begin f:=false; break; end; if f=true then begin writeln('Lucky Word'); write(k); end else begin writeln('No Answer'); write('0'); end; end.
相关文章推荐
- 普及练习场 简单的模拟 进制转换
- 普及练习场 简单的模拟 机器翻译
- 普及练习场 简单的模拟 排座椅
- 普及练习场 简单的模拟 多项式输出
- 普及练习场 简单的模拟 铺地毯
- 普及练习场 简单的模拟 笨小猴
- 普及练习场 交叉模拟 均分纸牌
- 普及练习场 简单数学 [SDOI2008]仪仗队
- 普及练习场 简单数学 又是毕业季I
- 普及练习场 交叉模拟 花生采摘
- 普及练习场 交叉模拟 乒乓球
- 普及练习场之交叉模拟
- 普及练习场 简单数学 A % B Problem
- 普及练习场 交叉模拟 字符串的展开
- 普及练习场 简单数学问题 火星人
- 普及练习场 简单数学 末日的传说
- 普及练习场 交叉模拟 税收与补贴问题
- 普及练习场 简单数学问题 约数研究
- 用AJAX实现google输入自动完成的简单模拟
- 使用java简单模拟ping和telnet的实现