K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

#include <bits/stdc++.h>
using namespace std;
const long long maxint=3*1e5+10;
long long a[maxint],i,n,x,k,c[maxint]={0};
int main()
{
    freopen("leaknum.inp","r",stdin);
    freopen("leaknum.out","w",stdout);
    cin>>n;
    for (i=1; i<=n; i++)
    {
        cin>>x;
        if (x<=n) c[x]++;
    }
    i=0;
    while (c[i]>0)
        i=i+1;
    cout<<i;
    return 0;
}

 

23 tháng 12 2019

var
i,j,n,k,x,vt:longint;
s,r,s1,s2:ansistring;
A:array[0..101] of boolean;
B:array[0..101] of longint;

BEGIN
assign(input,'gach.inp'); reset(input);
assign(output,'gach.out'); rewrite(output);

read(n,k);

for i:=1 to 101 do
A[i]:=true;

A[1]:=false;
for i:=1 to trunc(sqrt(101)) do
if (A[i] = true) then
for j:=2 to 101 div i do
A[i*j]:=false;

vt:=0;
for i:=1 to 101 do
if (A[i] =true) then
begin
inc(vt);
B[vt]:=i;
end;

for i:=1 to n do
begin
str(B[i],r);
s:=s+r;
end;

x:=length(s)-k-1;
vt:=1;
while (x >= 0) do
begin
for j:=vt to length(s)-x do
if (s[vt] > s[j]) then vt:=j;
s1:=s1+s[vt];
dec(x);
inc(vt);
end;

x:=length(s)-k-1;
vt:=1;
while (x >= 0) do
begin
for j:=vt to length(s)-x do
if (s[vt] < s[j]) then vt:=j;
s2:=s2+s[vt];
dec(x);
inc(vt);
end;

writeln(s);
writeln(s1);
writeln(s2);

close(input);
close(output);
END.

23 tháng 12 2019

không ai thèm trả lời thì thôi tự trl cho nó nhanh

23 tháng 11 2019

câu hỏi này bạn nên để chị @Nguyễn Minh Lệ trả lời giúp bạn

24 tháng 11 2019

Program hotrotinhoc;

var a,b,max,x,d,i,y: longint;

n,k,s: string;

begin

readln(n); s:=n;

while length(n)<>1 do

begini:=i+1;
k:=k+

s[i];

val(k,x);

delete(n,1,1);

val(n,y);

d:=x+y;

if d>max then

begin

max:=y+x;

a:=x;

b:=y;

end;

end;

write(a,' ',b);

readln

end.

12 tháng 7 2017

program bt;

uses crt;

var n,i,j:word;

a:array[1..100] of longint;

begin

clrscr;

write('nhap so n:');readln(n);

for i:=1 to n+1 do a[i]:=0;

a[1]:=1;

for i:=0 to n do

begin

for j:=i+1 downto 2 do a[j]:=a[j]+a[j-1];

for j:=1 to i+1 do write(a[j]:3);

writeln;

end;

readln;

end.


banh

2 tháng 1 2018

chuẩn men

29 tháng 6 2020

Bài bạn có 1 số lỗi về cú pháp. Và đề không yêu cầu sử dụng tệp .

VD lỗi : if uoc:=2 then S:=S+A;

Nhưng thuật toán vậy là đúng rồi. Mình sẽ tặng bạn GP ok

Cách 2:

uses crt;
var f:array[1..100]of integer;
n,i,t,kt,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
f[1]:=1;
f[2]:=1;
i:=2;
repeat
i:=i+1;
f[i]:=f[i-1]+f[i-2];
until i=n;
t:=0;
for i:=1 to n do
if f[i]>1 then
begin
kt:=0;
for j:=2 to f[i]-1 do
if f[i] mod j=0 then kt:=1;
if kt=0 then t:=t+f[i];
end;
writeln(t);
readln;
end.

24 tháng 5 2019

uses crt;
var n,n1,s:real;
begin
clrscr;
write('Nhap n: ');readln(n);
n1:=2*n+1;
s:=((n1 - 1)/2+1)*(n1 + 1)/2;
write(s:0:0);
readln
end.

var i,n,d:word;
t,b,kt:array[1..10] of word;

procedure nhap;
var f:text;
begin
assign(f,'dulieu.inp');
reset(f);
readln(f,n);
for i:=1 to n do read(f,t[i]);
close(f);
fillchar(b,sizeof(kt),0);
end;

procedure tailap;
var i,j,d:integer;
begin
for i:=1 to n do
begin
d:=0;
for j:=1 to n do
begin
if b[j]=0 then d:=d+1;
if d=t[i]+1 then break;
end;
b[j]:=i;
end;
end;

BEGIN
nhap;
tailap;
for i:=1 to n do write(b[i],' ');
readln
END.