欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

2020.05.02【NOIP普及组】模拟赛C组31

程序员文章站 2024-03-18 23:26:10
...

链接

T1:

简单爆力

var
i,j,k,m,n,max,min:longint;
a:array['a'..'z']of longint;
c:char;
begin
    assign(input,'word.in');
    assign(output,'word.out');
    reset(input);
    rewrite(output);
    min:=maxlongint;
    read(c);
    while not eoln do
    begin
        inc(a[c]);
        read(c);
    end;
    inc(a[c]);
    for c:='a' to 'z' do
    begin
        if a[c]<>0 then
        begin
            if a[c]>max then max:=a[c];
            if a[c]<min then min:=a[c];
        end;
    end;
    k:=max-min;
    if (k=1)or(k=0) then begin writeln('No Answer');writeln(0); end
    else
    begin
        for j:=2 to trunc(sqrt(k)) do
        if k mod j=0 then begin m:=1;break; end;
        if m=0 then
        begin
            writeln('Lucky Word');
            writeln(k);
        end;
    end;
    close(input);
    close(output);
end.

T2:

转换成二进制康康

你发现了什么

2020.05.02【NOIP普及组】模拟赛C组31

#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int m,n,x,y,k;
int a[1001010];
long long ans;
int main(){
	freopen("sequence.in","r",stdin);
	freopen("sequence.out","w",stdout);
	cin>>n>>k;
	while(k!=0){
		m++;
		a[m]=k%2;
		k/=2;
	}
	for(int i=1;i<=m;i++){
		ans=ans+pow(n,i-1)*a[i];
	}
	cout<<ans;
	return 0;
}

T3:

爆搜一下,你就知道

var
i,j,k,m,n,x,y,t:longint;
a:array[0..1000]of char;
s:string;
procedure dfs(x,y:longint;ss:string);
begin
    if(x>t-m+2)then exit;
    if(y=n)then
    begin
        if(k>0)and(k<=5) then
        begin
            writeln(ss);
            inc(k);
        end;
        if(k=0)then if(ss=s)then k:=1;
        exit;
    end;
    dfs(x+1,y+1,ss+a[x]);
    dfs(x+1,y,ss);
end;
begin
    assign(input,'count.in');
    assign(output,'count.out');
    reset(input);
    rewrite(output);
    readln(m,t,n);
    read(s);
    j:=0;
    for i:=m to t do
    begin inc(j);a[j]:=chr(i+96); end;
    dfs(1,0,'');
    close(input);
    close(output);
end.

T4:

设一个4维的f
分别表示小渊和小轩的位置的最大值
然后就

#include<iostream>
#include<cstdio>
using namespace std;
int n,m,a[100][100],f[51][51][51][51];
int main(){
	freopen("message.in","r",stdin);
	freopen("message.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			for(int i1=1;i1<=n;i1++){
				for(int j1=j+1;j1<=m;j1++){
					f[i][j][i1][j1]=max(f[i][j][i1][j1],
					max(f[i-1][j][i1-1][j1],max(
					f[i-1][j][i1][j1-1],max(
					f[i][j-1][i1-1][j1],f[i][j-1][i1][j1-1])))+a[i][j]+a[i1][j1]);
				}
			}
		}
	}
	cout<<f[n][m-1][n-1][m];
	return 0;
}
相关标签: 比赛