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.
var n,x,y,z:integer;
begin
assign(input,'nghiemnt.inp');reset(input);
assign(output,'nghiemnt.out');rewrite(output);
readln(n);
for x:=0 to n do
for y:=0 to n-x do
begin
z:=n-x-y;
writeln(x,' ',y,' ',z);
end;
writeln('0 0 0');
end.
var n,i,j,h:longint;kt:boolean;
function nt(n:int64):boolean;
var k:longint;
begin
if n<2 then exit(false) else if n<4 then exit(true);
if (n mod 2=0) or (n mod 3=0) then exit(false);
for k:=1 to (trunc(sqrt(n))+1) div 6 do
if (n mod (6*k+1)=0) or (n mod (6*k-1)=0) then exit(false);
exit(true);
end;
begin
assign(input,'nghiemnt.inp');reset(input);
assign(output,'nghiemnt.out');rewrite(output);
readln(n);kt:=false;
for i:=2 to n do
begin
if nt(i) then
for j:=n-i downto 2 do
begin
h:=n-i-j;
if nt(j)and nt(h) then begin writeln(i,' ',j,' ',h);kt:=true; end;
end;
end;
if kt=false then write('khong co bo so nao');
end.
#include <iostream>
#include <vector>
using namespace std;
vector<int> primeFactors(int n) {
vector<int> factors;
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
factors.push_back(i);
n /= i;
}
}
if (n > 1) factors.push_back(n);
return factors;
}
int main() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
vector<int> factors = primeFactors(k);
int sum = accumulate(a.begin(), a.end(), 0);
vector<vector<bool>> dp(n+1, vector<bool>(sum+1, false));
dp[0][0] = true;
for (int i = 1; i <= n; ++i) {
for (int j = 0; j <= sum; ++j) {
dp[i][j] = dp[i-1][j];
if (j >= a[i-1]) {
for (int factor : factors) {
if (a[i-1] % factor == 0) {
dp[i][j] = dp[i][j] || dp[i-1][j-a[i-1]];
break;
}
}
}
}
}
for (int j = 0; j <= sum; ++j) {
if (dp[n][j]) {
cout << j << endl;
break;
}
}
return 0;
}
Câu 1: C
Câu 2: A
Câu 3: B
Câu 4: A
Câu 5: C
Câu 6: A
Câu 7: C
Câu 9: D
Câu 10: A
Program HOC24;
const fi='dlv.inp';
fo='dulieura.out';
var f: text;
i,d,n: integer;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,n);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
d:=0;
for i:=3 to n do if i=sqr(trunc(sqrt(i))) then d:=d+1;
writeln(f,d);
for i:=3 to n do if i=sqr(trunc(sqrt(i))) then write(f,i,' ');
close(f);
end;
begin
ip;
out;
end.
uses crt;
const fi='standard.inp';
fo='standard.out';
var f1,f2:text;
a:array[1..100]of integer;
i,j,n,dem,t:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
readln(f1,a[i]);
{--------------------xu-ly------------------}
for i:=1 to n do
begin
write(f2,a[i],' co so uoc la: ');
dem:=0;
t:=0;
for j:=1 to a[i] do
if a[i] mod j=0 then
begin
dem:=dem+1;
t:=t+j;
end;
writeln(f2,dem.,' tong uoc la: ',t);
end;
close(f1);
close(f2);
readln;
end.
var n:qword;i:longint;
a:array[1..1000] of longint;
function du(x:qword):qword;
var k,d:longint;
begin
d:=0;
for k:=1 to trunc(sqrt(x)) do
begin
if x mod k=0 then
begin
d:=d+2;
end;
end;
if sqrt(x)=trunc(sqrt(x)) then dec(d);
du:=d;
end;
function tu(s:qword):qword;
var t:qword;j:longint;
begin
t:=0;
for j:=1 to trunc(sqrt(s)) do
if s mod j=0 then t:=t+j+(s div j);
tu:=t;
end;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
writeln(a[i],' co ',du(a[i]),' uoc. Tong uoc la: ',tu(a[i]));
readln;
end.