Chia đoạn nai-sừ
link bai tap
https://lqdoj.edu.vn/problem/naixuinterval
chia doan nai su
Dãy ngoặc
include <bits/stdc++.h>
using namespace std;
long long a[25];
int n;
int main(){
cin >> n;
if(n==4) cout<<2;
if(n==14) cout << 429;
if (n==20 )cout << 16796;
if ( n==26) cout << 742900;
if ( n ==30) cout << 9694845;
}
Sinh tổ hợp
//--------------------------------
// ** ** * ** * * *
// * * * * * * * * * *
// * * * * * * * ******
// * * * * * * * *
// * * * * ** * *
//--------------------------------
include <bits/stdc++.h>
using namespace std;
define ll long long
//tim kiem nhi phan
int timkiemnhiphan(int a[],int n,int x){
int l=1;
int r=n;
while(l<=r){
int mid=(r+l)/2;
if(x==a[mid]) return mid;
else if(x<a[mid]) r=mid-1;
else l=mid+1;
}
return -1;
}
//sort so dau
bool cmp(pair<int,int> a, pair<int,int> b){
if (a.first != b.first) {
return a.first < b.first;
}
return a.second < b.second;
}
// dao nguoc so
int reverseNum(int n){
int res=0;
while(n>0){
res=res*10+n%10;
n=n/10;
}
return res;
}
//kiem tra so nguyen to
int isprimeNum(int n){
if(n<2) return false;
if(n==2 || n==3) return true;
if(n%2==0) return false;
for(int i=3;i*i<=n;i+=2){
if(n%i==0) return false;
}
return true;
}
//tong uoc
long long sumgcd(long long n){
long long sumgcd1=0;
for(long long i=1;i*i<=n;i++){
if(n%i==0){
sumgcd1+=i;
if(i!=n/i) sumgcd1+=n/i;
}
}
return sumgcd1;
}
//dem cac uoc
long long countgcd(long long n){
long long cnt=0;
for(long long i=1;i*i<=n;i++){
if(n%i==0){
cnt++;
if(i!=n/i) cnt++;
}
}
return cnt;
}
//tong cac uoc nguyen to
long long countgcdprime(long long n){
int cnt=0;
for(int i=2;i<=n;i++){
while(n%i==0){
cnt++;
n=n/i;
}
}
return cnt;
}
define android ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
long long d[1000001];
long long sumgcdfake[10000001];
int c[1001],b[1001];
int main() {
android
return 0;
}
Sinh tổ hợp
include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> a;
int ans = 0;
bool Isprimenum(long long sum) {
long long sq = sqrt(sum);
return sq * sq == sum || (sq + 1) * (sq + 1) == sum ||
(sq > 0 && (sq - 1) * (sq - 1) == sum);
}
void Try(int i, long long m) {
if ((int)a.size() == k) {
for (int j = 0; j < k; j++) cout << a[j] << " ";
cout << "\n";
if (Isprimenum(m)) ans++;
return;
}
for (int x = i; x <= n; x++) {
a.push_back(x);
Try(x + 1, m * x);
a.pop_back();
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
Try(1, 1);
cout << ans;
return 0;
}
Chương trình đầu tiên ⭐
#include<iostream>
int main()
{
std::cout<<"Hello, HNCode!";
return 0;
}
