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 <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n,k;
cin >> n >> k;
int a[n];
for (int i=0;i<n;i++)
cin >> a[i];
sort(a,a+n);
cout << a[k-1];
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000006];
long long n;
int main()
{
for(int i=1;i<=1000006;i++){
a[i]=i*i;
}
cin>>n;
for(int i=1;i<=n;i++){
if(a[i]%n==0){cout<<a[i]/n;break;}
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,dem,i;
int main()
{
freopen("bl1.inp","r",stdin);
freopen("bl1.out","w",stdout);
cin >> n;
for( i = 2; i <= n; i++)
{
dem = 0;
while(n % i == 0)
{
++dem;
n=n/i;
}
if(dem)
{
cout<<i;
if (dem>1) cout <<"^"<<dem;
if (n>i){
cout <<" * ";
}
}
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
unsigned long long a[1000],i,n,uc;
//chuongtrinhcon
unsigned long long ucln(long long a,long long b)
{
if (b==0) return(a);
else return(ucln(b,a%b));
}
//chuongtrinhchinh
int main()
{
freopen("sn3.inp","r",stdin);
freopen("uc.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
uc=ucln(a[1],a[2]);
for (i=3; i<=n; i++)
uc=ucln(uc,a[i]);
cout<<uc;
return 0;
}
Bạn tham khảo code này nhé.
Uses crt;
Const fo = 'chenxau.out';
dau: array[1..3] of String[1]= ('','-','+');
s:array[1..9] of char=('1','2','3','4','5','6','7','8','9');
Var d:array[1..9] of String[1];
m:longInt;
f:text;
k:integer;
found:boolean;
Procedure Init;
Begin
Write('Cho M=');
Readln(m);
found:=false;
end;
Function tinh(s:string):longint;
Var i,t:longint;
code:integer;
Begin
i:=length(s);
While not(s[i] in ['-','+']) and (i>0) do dec(i);
val(copy(s,i+1,length(s)-i),t,code);
If i=0 then begin tinh:=t; exit; end
else
begin
delete(s,i,length(s)-i+1);
If s[i]='+' then tinh:=t+tinh(s);
If s[i]='-' then tinh:=tinh(s)-t;
end;
End;
Procedure Test(i:integer);
Var st:string; j:integer;
Begin
st:='';
For j:=1 to i do st:=st+d[j]+s[j];
If Tinh(st) = m then begin writeln(f,st); found:=true; end;
End;
Procedure Try(i:integer);
Var j:integer;
Begin
for j:=1 to 3 do
begin
d[i]:=dau[j]; Test(i);
If i<9 then try(i+1);
end;
End;
BEGIN
Clrscr;
Init;
Assign(f,fo);Rewrite(f);
for k:=1 to 2 do
begin
d[1]:=dau[k];
Try(2);
end;
If not found then write(f,'khong co ngiem');
Close(f);
END.
Cảm ơn ạ.