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.
```cpp
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
int n;
std::cout << "Enter the number of integers (n < 10^5): ";
std::cin >> n;
std::vector<int> numbers(n); std::cout << "Enter " << n << " integers: "; for (int i = 0; i < n; ++i) { std::cin >> numbers[i]; } int sumOfOdd = 0; for (int i = 0; i < n; ++i) { if (numbers[i] % 2 != 0) { sumOfOdd += numbers[i]; } } std::sort(numbers.begin(), numbers.end()); std::cout << "Sum of odd integers: " << sumOfOdd << std::endl; std::cout << "Sorted sequence: "; for (int i = 0; i < n; ++i) { std::cout << numbers[i] << " "; } std::cout << std::endl; return 0;
}
```
#include <iostream>
using namespace std;
int main()
{
int i,n,a,b,kt,j;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
for (i=a; i<=b; i++)
{
if (i>2)
{
kt=0;
for (j=2; j<=i-1; j++)
if (i%j==0) kt=1;
if (kt==0) cout<<i<<" ";
}
}
return 0;
}
program hoidaptinhoc;
uses crt;
var K,N,X,Y,M,i : longint;
z : string;
BEGIN
clrscr;
writeln('Nhap so dong trong moi trang cua quyen sach: '); readln(K);
writeln('Nhap so thu tu cua dong: '); readln(N);
if (N mod K) = 0 then begin X:=N div K; Y:=K end;
if (N mod K) <> 0 then begin X:= (N div K) + 1; Y:=N mod K end;
M:=0;
for i:=1 to X do
begin
str(i,z);
M:=M+length(z);
end;
writeln('X= ',X,' Y= ',Y);
writeln('M= ',M);
readln;
END.
uses crt;
var n,i,dem:integer;
{----------------ham-kiem-tra-so-nguyen-to---------------------------}
function ktnt(x:integer):boolean;
var kt:boolean;
i:integer;
begin
kt:=true;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then kt:=false;
if kt=true then ktnt:=true
else ktnt:=false;
end;
{-----------------chuong-trinh-chinh-----------------------}
begin
clrscr;
write('Nhap n='); readln(n);
dem:=0;
for i:=2 to n do
if (n mod i=0) and (ktnt(i)=true) then inc(dem);
writeln(dem);
readln;
end.
#include <iostream>
#include <map>
using namespace std;
int main() {
int n;
cin >> n;
map<int, int> count;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
count[x]++;
}
int ans = 0;
for (auto p : count) {
int x = p.second;
ans += (x * (x - 1)) / 2;
}
cout << ans;
return 0;
}