复赛1.docx

上传人:b****5 文档编号:8002067 上传时间:2023-01-27 格式:DOCX 页数:11 大小:16.40KB
下载 相关 举报
复赛1.docx_第1页
第1页 / 共11页
复赛1.docx_第2页
第2页 / 共11页
复赛1.docx_第3页
第3页 / 共11页
复赛1.docx_第4页
第4页 / 共11页
复赛1.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

复赛1.docx

《复赛1.docx》由会员分享,可在线阅读,更多相关《复赛1.docx(11页珍藏版)》请在冰豆网上搜索。

复赛1.docx

复赛1

1.1的个数

vari,j,k,l,n,p,ans:

dword;

s:

string;

proceduresetup;

begin

assign(input,'bro.in');

reset(input);

assign(output,'bro.out');

rewrite(output);

end;

procedureendit;

begin

close(input);

close(output);

end;

begin

setup;

readln(n);

str(n,s);

l:

=length(s);

fori:

=1toldo

begin

p:

=trunc(exp(ln(10)*(l-i))+0.5);

j:

=n-k*p*10-(ord(s[i])-48)*p;

inc(ans,k*p);

ifs[i]='1'theninc(ans,j+1)

elseifs[i]<>'0'theninc(ans,p);

k:

=k*10+ord(s[i])-48;

end;

writeln(ansmod32749);

endit;

end.

 

2.f91

vari,n:

longint;

begin

assign(input,'f.in');

reset(input);

assign(output,'f.out');

rewrite(output);

read(n);

whilen>0do

begin

ifn<=100thenwriteln('f91(',n,')=',91)

elsewriteln('f91(',n,')=',n-10);

read(n);

end;

close(output);

close(input);

end.

 

3.H数问题

programex1(input,output);

constmark:

array[1..4]ofinteger=(2,3,5,7);

vari,h,k,n,order:

longint;

begin

assign(input,'h.in');reset(input);

assign(output,'h.out');rewrite(output);

readln(n);

h:

=1;order:

=1;

whileorder

begin

h:

=h+1;k:

=h;

fori:

=1to4do

whilekmodmark[i]=0dok:

=kdivmark[i];

ifk=1thenorder:

=order+1

end;

writeln(h);

close(input);close(output);

end.

 

4.n的阶乘值问题

vara:

array[1..160]oflongint;

n,i,j,ans:

longint;

functionprime(n:

longint):

boolean;

vari:

longint;

begin

ifn=1thenexit(false);

fori:

=2toround(sqrt(n))do

ifnmodi=0thenexit(false);

exit(true);

end;

begin

assign(input,'test3.in');

assign(output,'test3.out');

reset(input);

rewrite(output);

readln(n);

fillchar(a,sizeof(a),0);

a[1]:

=1;

fori:

=2tondo

begin

forj:

=1to159do

a[j]:

=a[j]*i;

forj:

=1to159do

ifa[j]>=10then

begin

a[j+1]:

=a[j+1]+a[j]div10;

a[j]:

=a[j]mod10;

end;

end;

ans:

=0;

fori:

=1to160do

ans:

=ans+a[i];

write(ans,'');

ifprime(ans)thenwriteln('T')

elsewriteln('F');

close(input);

close(output);

end.

 

5.N皇后问题

programzmc_151(input,output);

vara,b,c:

array[-100..100]ofboolean;

z:

array[1..100]ofinteger;

n,tot:

integer;

procedurewr;

vari:

integer;

begin

fori:

=1tondowrite(z[i]:

5);

writeln;inc(tot);

end;

proceduretry(x:

integer);

vari:

integer;

begin

fori:

=1tondo

if(a[i])and(b[i+x])and(c[i-x])then

begin

z[x]:

=i;

a[i]:

=false;

b[i+x]:

=false;

c[i-x]:

=false;

ifx=nthenwr

elsetry(x+1);

a[i]:

=true;

b[i+x]:

=true;

c[i-x]:

=true;

end;

end;

begin

fillchar(a,sizeof(a),#1);

fillchar(b,sizeof(b),#1);

fillchar(c,sizeof(c),#1);

assign(input,'word.in');

reset(input);

assign(output,'word.out');

rewrite(output);

readln(input,n);

try

(1);

iftot=0thenwriteln('nosolute!

');

close(input);close(output);

end.

 

6.阿姆斯特朗数

constmaxlen=7;

vari,j,currentnumber,highest,sum,total:

longint;

digit:

array[0..maxlen+1]ofinteger;

power:

array[0..9,0..maxlen]oflongint;

begin

assign(output,'arms.out');

rewrite(output);

fori:

=0to9do

begin

power[i,0]:

=1;

forj:

=1tomaxlendopower[i,j]:

=power[i,j-1]*i

end;

fori:

=1tomaxlendodigit[i]:

=0;

digit[3]:

=1;highest:

=3;currentnumber:

=100;total:

=0;

whiledigit[maxlen+1]=0do

begin

sum:

=0;

fori:

=1tohighestdosum:

=sum+power[digit[i],highest];

ifsum=currentnumber

thenbegintotal:

=total+1;

write(currentnumber:

maxlen+5);

iftotalmod6=0thenwritelnend;

digit[1]:

=digit[1]+1;i:

=1;

whiledigit[i]=10do

begindigit[i+1]:

=digit[i+1]+1;digit[i]:

=0;i:

=i+1end;

ifi>highestthenhighest:

=i;

currentnumber:

=currentnumber+1

end;

writeln;

close(output);

end.

 

7.比身高

programnum;

var

a:

array[1..1000]ofinteger;

n,i,j,t1,t2,sum:

integer;

begin

assign(input,'num.in');

reset(input);

assign(output,'num.out');

rewrite(output);

readln(n);

fori:

=1tondo

readln(a[i]);

sum:

=0;

fori:

=1tondo

begin

t1:

=0;

forj:

=1toi-1do

ifa[i]

theninc(t1);

t2:

=0;

forj:

=i+1tondo

ifa[i]

theninc(t2);

ift1=t2

theninc(sum);

end;

writeln(sum);

close(input);

close(output);

end.

 

8.纯粹化信息

vara:

array['A'..'Z']ofboolean;

s:

string;

i:

longint;

temp:

char;

PD:

BOOLEAN;

begin

assign(input,'krunch.in');reset(input);

assign(output,'krunch.out');rewrite(output);

fillchar(a,sizeof(a),true);

A['A']:

=FALSE;

A['E']:

=FALSE;

A['I']:

=FALSE;

A['O']:

=FALSE;

A['U']:

=FALSE;

s:

='';

whilenot(eoln)do

begin

read(temp);

PD:

=((temp='')and(temp<>s[length(s)]))OR((TEMP<>'')AND(temp<>',')and(temp<>'.')and(temp<>'?

')and(A[TEMP]))or((temp=',')or(temp='.')or(temp='?

'));

ifPDthenbegins:

=s+temp;IF(TEMP<>'')and(temp<>'.')and(temp<>'?

')THENa[temp]:

=false;end;

end;

fori:

=1tolength(s)do

if((s[i]=',')or(s[i]='.')or(s[i]='?

'))and(s[i-1]='')thendelete(s,i-1,1);

ifs[1]=''thendelete(s,1,1);

ifs[length(s)]=''thendelete(s,length(s),1);

writeln(s);

close(input);

close(output);

end.

 

9.打印日历

constmonth:

array[1..12]ofstring[10]

=('Janu','Fabr','Marc','Apri','May','June',

'July','Augu','Sept','Octo','Nove','Dece');

day:

array[0..6]ofstring[10]

=('SUN','MON','TUE','WEN','THU','FRI','SAT');

vari,j,k,y,first:

longint;

ds,ts:

array[1..12]oflongint;

begin

assign(input,'cal.in');

reset(input);

readln(y);

first:

=(y+(y-1)div4-(y-1)div100+(y-1)div400)mod7;

ds[1]:

=31;ds[2]:

=28;ds[3]:

=31;ds[4]:

=30;ds[5]:

=31;ds[6]:

=30;

ds[7]:

=31;ds[8]:

=31;ds[9]:

=30;ds[10]:

=31;ds[11]:

=30;ds[12]:

=31;

if(ymod400=0)or(ymod4=0)and(ymod100<>0)theninc(ds[2]);

ts[1]:

=first;

fori:

=2to12dots[i]:

=ts[i-1]+ds[i-1];

 

assign(output,'cal.out');

rewrite(output);

write('':

3);

fori:

=1to12dowrite(month[i]:

6);

writeln;

fori:

=1to3do

forj:

=0to6do

begin

write(day[j]);

fork:

=1to12do

begin

if(i-1)*7+j+1-ts[k]mod7>=1

thenwrite((i-1)*7+j+1-ts[k]mod7:

3)

elsewrite('':

3);

if(i+2)*7+j+1-ts[k]mod7<=ds[k]

thenwrite((i+2)*7+j+1-ts[k]mod7:

3)

elsewrite('':

3)

end;

writeln;

end;

close(output)

end.

 

10.到天宫做客

programheaven;

constday:

array[1..11]oflongint

=(31,29,31,30,31,30,31,31,30,31,30);

vari,j,n,m,d,t,max:

longint;

s:

array[1..367]ofboolean;

begin

assign(input,'heaven.in');

reset(input);

assign(output,'heaven.out');

rewrite(output);

read(n);

fillchar(s,sizeof(s),false);

s[367]:

=true;

fori:

=1tondo

begin

read(m,d);

{writeln(m,'',d);}

t:

=0;

forj:

=1tom-1dot:

=t+day[j];

t:

=t+d;

s[t]:

=true;

end;

t:

=0;max:

=0;

fori:

=1to367do

ifs[i]then

begin

ifi-t-1>maxthenmax:

=i-t-1;

t:

=i

end;

writeln((max*24*60*60+183)div366);

close(input);

close(output);

end.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育 > 初中作文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1