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.
#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;
}
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.