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.
Program HOC24;
const fi='Cau1.INP';
fo='Cau2.OUT';
var i,a,b,c,t,d: integer;
f: text;
function ucln(x,y: integer): integer;
var t: integer;
begin
while y<>0 do
begin
t:= x mod y;
x:=y;
y:=t;
end;
ucln:=x;
end;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,a,b,c);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
for i:=b to c do
begin
if i mod a=0 then write(f,i,' ');
t:=t+i;
end;
writeln(f);
while t<>0 do
begin
t:=t div 10;
inc(d);
end;
writeln(f,d);
if ucln(a,b,c)=1 then write(f,1) else write(f,0);
close(f);
end;
begin
ip;
out;
end.
Program hotrotinhoc;
const fi='cau2.inp';
fo='cau2.out';
var f: text;
s: ansistring;
i,n,d,max,min: integer;
a: array[1..1000] of string;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,s);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
s:=s+' ';
while length(s)<>0 do
begin
inc(d);
min:=1001;
max:=0;
a[d]:=copy(s,1,pos(' ',s)-1);
delete(s,1, pos(' ',s));
end;
for i:=1 to d do
begin
if length(a[i])>max then max:=length(a[i]);
if length(a[i])<min then min:=length(a[i]);
end;
write(f,min,' ',max);
close(f);
end;
begin
ip;
out;
end.
Program hotrotinhoc_hoc24;
const fi='CAPSO.INP';
fo='CAPSO.OUT';
var a: array[1..100] of integer;
i,j,n,x,d: integer;
f: text;
procedure ip;
begin
assign(f,fi);
reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]);
readln(f);
read(f,x);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
d:=0;
for i:=1 to n do
for j:=i to n do
if i+j=x then inc(d);
write(f,d);
close(f);
end;
begin
ip;
out;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i;
int main()
{
freopen("dayd.inp","r",stdin);
freopen("dayd.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]>0) cout<<a[i]<<" ";
return 0;
}
uses crt;
const fi='dt.inp';
fo='dt.out';
var n,i,d,x,t,ln,kt:integer;
st:string;
a:array[1..100]of integer;
f1,f2:text;
begin
clrscr;
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
{-------------------------cau-a-----------------------}
str(n,st);
d:=length(st);
for i:=1 to d do
val(st[i],a[i],x);
t:=0;
for i:=1 to d do
begin
if a[i]=0 then t:=t+6;
if a[i]=1 then t:=t+2;
if a[i]=2 then t:=t+5;
if a[i]=3 then t:=t+5;
if a[i]=4 then t:=t+4;
if a[i]=5 then t:=t+5;
if a[i]=6 then t:=t+6;
if a[i]=7 then t:=t+3;
if a[i]=8 then t:=t+7;
if a[i]=9 then t:=t+6;
end;
writeln(f2,t);
{-----------------------cau-b---------------------------}
ln:=a[1];
for i:=1 to d do
if ln<a[i] then ln:=a[i];
writeln(f2,ln);
{--------------------cau-c-------------------------------}
kt:=0;
for i:=1 to d-1 do
if a[i]>a[i+1] then kt:=1;
if kt=0 then writeln(f2,'T')
else begin
kt:=0;
for i:=1 to d-1 do
if a[i]<a[i+1] then kt:=1;
if kt=0 then writeln(f2,'L')
else writeln(f2,'0');
end;
close(f1);
close(f2);
readln;
end.
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long n,i;
//chuongtrinhcon
int demuoc(long long n)
{
int dem=0;
for (long long i=1; i<=n; i++)
if (n%i==0) dem++;
return (dem);
}
//chuongtrinhchinh
int main()
{
freopen("tamuoc.inp","r",stdin);
freopen("tamuoc.out","w",stdout);
cin>>n;
long long dem=0;
for (i=1; i<=n; i++)
if (demuoc(i)==3) dem++;
cout<<dem;
return 0;
}
1.
#include <bits/stdc++.h>
using namespace std;
int A,n,i;
int main()
{
cin>>n;
A=0;
For (i=0;i<=n;i++)
A=A+1/i;
cout<<A;
Return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define nmax 1000007
#define ll long long
long long a[nmax];
long long gt(long long a)
{
return a*(a+1)/2;
}
signed main()
{
long long n, m, q;
cin >> n >> m >> q;
cout << (gt(m) - gt(n-1)) % q;
}