Editorial for Xúc xắc bò


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Lưu ý: Các code mẫu dưới đây chỉ mang tính tham khảo và có thể không AC được bài tập này

Code mẫu của flashmt

var a,b,c:byte;
    d:array[3..80] of integer;
    kq:integer;

procedure re;
begin
    read(a,b,c);
end;

procedure pr;
var i,j,k:byte; max:integer;
begin
    fillchar(d,sizeof(d),0);
    for i:=1 to a do
        for j:=1 to b do
            for k:=1 to c do
                inc(d[i+j+k]);
    max:=0;
    for i:=3 to 80 do
        if d[i]>max then
        begin
            max:=d[i];
            kq:=i;
        end;
end;

procedure wr;
begin
    write(kq);
end;

begin
    re;
    pr;
    wr;
end.

Code mẫu của happyboy99x

#include <cstdio>

int s[200];
#define REP(i,n) for( int i = 1, _n = (n); i <= _n; ++i )

int main() {
    int a, b, c; scanf( "%d%d%d", &a, &b, &c );
    REP(i, a) REP(j, b) REP(k, c) ++s[i+j+k];
    int num = 0;
    REP(i, 199) if ( s[i] > s[num] ) num = i; 
    printf( "%d\n", num );
    return 0;
}

Code mẫu của ladpro98

program bones;
uses    math;
const   fi='';
var     f:array[1..100] of longint;
        res,s1,s2,s3:longint;

procedure input;
var     inp:text;
begin
        assign(inp,fi);
        reset(inp);
        readln(inp,s1,s2,s3);
        close(inp);

end;

procedure back;
var     i,j,k:longint;
begin
        for i:=1 to s1 do
        for j:=1 to s2 do
        for k:=1 to s3 do
        inc(f[i+j+k]);
end;

procedure getResult;
var     i:longint;
begin
        res:=1;
        for i:=1 to 100 do
        if f[res]<f[i] then
        res:=i;
end;

procedure output;
begin
        write(res);
end;

begin
        input;
        back;
        getResult;
        output;
end.

Code mẫu của RR

var
  cnt:array[1..100] of longint;
  x,y,z,a,b,c:longint;
begin
  read(x,y,z);
  for a:=1 to x do
  for b:=1 to y do
  for c:=1 to z do
    inc(cnt[a+b+c]);

  x:=1;
  for a:=2 to 100 do
    if cnt[a]>cnt[x] then x:=a;

  writeln(x);
end.

Code mẫu của hieult

#include <stdio.h>
main()
{
int s1,s2,s3,a[100],max=0,x;
scanf("%d %d %d",&s1,&s2,&s3);
for(int m=3;m<=s1+s2+s3;m++)
  {
  a[m]=0;
  for(int i=1;i<=s1;i++)
    for(int j=1;j<=s2;j++)
      for(int k=1;k<=s3;k++)
        if(m==i+j+k)
         a[m]++;
  if(max<a[m])
    {
    max=a[m];
    x=m;
    }
  }
printf("%d",x);
}

Code mẫu của ll931110

Program BONES;
        Const
                input  = '';
                output = '';
        Var
                a: array[1..100] of integer;
            x,y,z: integer;

Procedure init;
          Var
                f: text;
          Begin
                Assign(f, input);
                        Reset(f);
                        Read(f, x, y, z);
                Close(f);
                Fillchar(a, sizeof(a), 0);
          End;

Procedure prob;
          Var
                i,j,k,value,max: integer;
                              f: text;
          Begin
                For i:= 1 to x do
                    For j:= 1 to y do
                        For k:= 1 to z do inc(a[i + j + k]);

                max:= 0;
                value:= 1;
                For i:= 1 to x + y + z do if max < a[i] then
                        Begin
                                max:= a[i];
                                value:= i;
                        End;

                Assign(f, output);
                        Rewrite(f);
                        Writeln(f, value);
                Close(f);
          End;

Begin
        init;
        prob;
End.

Code mẫu của skyvn97

#include<stdio.h>
#define MAX   100
long s,t,u;
long time[MAX];
long max,i,j,k,r;
int main(void)
{
    scanf("%ld",&s);
    scanf("%ld",&t);
    scanf("%ld",&u);
    max=0;
    for (i=1;i<=s;i=i+1)
        for (j=1;j<=t;j=j+1)
            for (k=1;k<=u;k=k+1)
                time[i+j+k]++;
    max=0;
    r=0;
    for (i=3;i<=s+t+u;i=i+1)
        if (time[i]>max) { max=time[i]; r=i;}
    printf("%ld",r);
}

Code mẫu của khuc_tuan

[s1,s2,s3] = [int(x) for x in raw_input().split()]
total = [0] * (s1 + s2 + s3 + 1)
for i in range(1,s1+1):
    for j in range(1,s2+1):
        for k in range(1,s3+1):
            total[i+j+k] += 1

r = max(total)
for x in range(len(total)):
    if total[x]==r:
        print x
        break

Comments

Please read the guidelines before commenting.


There are no comments at the moment.