LTNC25 OnTap
LTNC25 OnTap
#include <iomanip>
using namespace std;
double dienTich(double r) {
return 3.14 * r * r;
}
int main() {
float r, length, width;
cin >> r >> length >> width;
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
struct ToaDo {
double x, y;
};
istream &operator >> (istream &in, ToaDo &d) {
in >> d.x >> d.y;
return in;
}
main() {
ToaDo a;
cin >> a;
cout << a;
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
struct ToaDo {
double x, y;
};
main() {
ToaDo a, b;
cin >> a >> b;
cout << (a + b) << endl << (a - b);
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
struct ToaDo {
double x, y;
};
main() {
ToaDo a, b;
cin >> a >> b;
if (a < b)
cout << "nho hon";
else if (a > b)
cout << "lon hon";
else
cout << "trung nhau";
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
struct ToaDo {
double x, y;
};
return false;
}
return false;
}
// Tien to
ToaDo operator ++ (ToaDo &td) {
td.x += 1;
td.y += 1;
return td;
}
// Hau to
ToaDo operator ++ (ToaDo &td, int) {
ToaDo prev = td;
td.x += 1;
td.y += 1;
return prev;
}
// Tien to
ToaDo operator -- (ToaDo &td) {
td.x -= 1;
td.y -= 1;
return td;
}
// Hau to
ToaDo operator -- (ToaDo &td, int) {
ToaDo prev = td;
td.x -= 1;
td.y -= 1;
return td;
}
int main() {
ToaDo a;
cin >> a;
ToaDo b = a++;
cout << a << endl;
cout << --b;
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
struct ToaDo {
double x, y;
};
return false;
}
return false;
}
// Tien to
ToaDo operator ++ (ToaDo &td) {
td.x += 1;
td.y += 1;
return td;
}
// Hau to
ToaDo operator ++ (ToaDo &td, int) {
ToaDo prev = td;
td.x += 1;
td.y += 1;
return prev;
}
// Tien to
ToaDo operator -- (ToaDo &td) {
td.x -= 1;
td.y -= 1;
return td;
}
// Hau to
ToaDo operator -- (ToaDo &td, int) {
ToaDo prev = td;
td.x -= 1;
td.y -= 1;
return td;
}
struct Array {
int size;
ToaDo data[10];
ToaDo getMax() {
ToaDo res = data[0];
for (int i = 1; i < size; i++)
if (res < data[i])
res = data[i];
return res;
}
ToaDo sum() {
ToaDo res = data[0];
for (int i = 1; i < size; i++)
res = res + data[i];
return res;
}
};
int main() {
Array a;
cin >> a;
cout << a.getMax() << endl;
cout << a.sum();
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
template<typename T>
void timMax() {
T x, y, z;
cin >> x >> y >> z;
T ans = x;
if (ans < y) ans = y;
if (ans < z) ans = z;
int main() {
char kt;
cin >> kt;
if (kt == 'a')
timMax<int>();
if (kt == 'b')
timMax<double>();
if (kt == 'c')
timMax<char>();
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
template<typename T>
struct Array {
int size;
T data[100];
T tong() {
T ans = 0;
for (int i = 0; i < size; i++)
ans += data[i];
return ans;
}
};
template<typename T>
istream &operator >> (istream &in, Array<T> &a) {
a.size = 0;
while (in >> a.data[a.size])
a.size++;
return in;
}
template<typename T>
ostream &operator << (ostream &out, Array<T> a) {
out << fixed << setprecision(2);
out << a.tong();
return out;
}
int main() {
char kt;
cin >> kt;
if (kt == 'a') {
Array<int> a;
cin >> a;
cout << a;
}
if (kt == 'b') {
Array<double> b;
cin >> b;
cout << b;
}
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
bool cp(int n) {
return sqrt(n) == (int) sqrt(n);
}
int main() {
ifstream fin("input.txt");
int n = 0;
int a[100];
fin.close();
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
bool check(int n) {
for (int i = 2; i*i <= n; i++)
if (n % i == 0)
return false;
return n > 1;
}
int main() {
freopen("output.txt", "w", stdout);
int n = 0;
int a[100];
while (cin >> a[n]) n++;
for (int i = 0; i < n; i++)
if (check(a[i]))
cout << a[i] << ' ';
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <fstream>
using namespace std;
int div(int n) {
int res = 0;
return res;
}
int main() {
ifstream fin("input.txt");
ofstream fout("output.txt");
int n = 0;
int a[100];
fin.close();
fout.close();
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
double laiSuat(int n) {
if (n == 0)
return 1;
return 1.07 * laiSuat(n - 1);
}
int main() {
int n;
cin >> n;
cout << fixed << setprecision(2) << laiSuat(n);
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
using namespace std;
int virus(int n) {
if (n == 0)
return 1;
return 2 * virus(n - 1);
}
int main() {
int n;
cin >> n;
cout << virus(n);
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
using namespace std;
int sum(int n) {
if (n < 10)
return n;
int main() {
int n;
cin >> n;
cout << sum(n);
return 0;
}
---------------------------------------------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
int x, n;
cin >> x >> n;
cout << S(x, n);
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
using namespace std;
int A(int i) {
if (i == 0 || i == 1)
return i;
if (i % 2 == 0)
return A(i / 2);
else
return A(i / 2) + A(i / 2 + 1);
}
int main() {
int n;
cin >> n;
int ans = 0;
for (int i = 0; i <= n; i++)
ans = max(ans, A(i));
int A(int i) {
if (i == 0 || i == 1)
return i;
if (i % 2 == 0)
return A(i / 2);
else
return A(i / 2) + A(i / 2 + 1);
}
int main() {
int n;
cin >> n;
int ans = 0;
for (int i = 0; i <= n; i++)
ans = max(ans, A(i));
int main() {
int n, k;
cin >> n >> k;
cout << C(n, k);
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <stack>
using namespace std;
int main() {
string s;
cin >> s;
stack<char> st;
while (!st.empty()) {
cout << st.top();
st.pop();
}
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <stack>
using namespace std;
int main() {
int n;
cin >> n;
stack<int> st;
if (n == 0) {
cout << 0 << endl;
return 0;
}
while (n > 0) {
st.push(n % 2);
n /= 2;
}
while (!st.empty()) {
cout << st.top();
st.pop();
}
int main() {
string s;
cin >> s;
stack<char> st;
if (c == '(') {
st.push(c);
continue;
}
if (st.empty()) {
cout << "NO" << endl;
return 0;
}
st.pop();
}
if (st.empty())
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <queue>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int x;
queue<int> q;
for (int i = 0; i < n; i++) {
cin >> x;
q.push(x);
}
while (!q.empty()) {
cout << q.front() << ' ';
q.pop();
}
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <vector>
using namespace std;
int main() {
int x;
vector<int> v;
vector<int>::iterator it;
for (it = v.begin(); it != v.end(); it++)
cout << *it << ' ';
cout << endl;
vector<int>::reverse_iterator rit;
for (rit = v.rbegin(); rit != v.rend(); rit++)
cout << *rit << ' ';
return 0;
}
---------------------------------------------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
int main (){
int x,k,l,n,q;
cin>>n>>q;
vector <int> v;
for (int i=0 ; i<n;i++){
cin>>x;
v.push_back (x);
}
for (int i=0;i<q;i++){
cin>>l;
if (l==1){
cin>>x>>k;
v.insert(v.begin()+k,x);
}
else if (l==2){
cin>>k;
v.erase(v.begin()+k);
}
else {
cin >> k;
cout<< v[k]<<endl;
}
}
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int x;
vector<int> v;
sort(v.begin(), v.end());
return 0;
}
---------------------------------------------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
bool comp(int a, int b) {
return abs(a) > abs(b);
}
main() {
int x;
vector<int> v;
return 0;
}
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <algorithm>
using namespace std;
bool chinhPhuong(int n) {
return sqrt(n) == (int) sqrt(n);
}
int main() {
int x;
vector<int> v;
while (cin >> x)
v.push_back(x);
bool snt(int n) {
for (int i = 2; i*i <= n; i++)
if (n % i == 0)
return false;
return n > 1;
}
int main() {
int x;
vector<int> v;
sort(v.begin(), v.end());