VL09 - Tính S = x + x^2/2! + ... + x^n/n!
Xem dạng PDF
Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Tác giả:
Dạng bài
Ngôn ngữ cho phép
C, C#, C++, Go, Java, Pascal, Perl, PHP, PyPy, Python, Ruby, Rust, Scratch, Swift
Viết chương trình tìm ~S~ biết: $$S = x + \frac{x^2}{2!} +\frac{x^3}{3!} + ... +\frac{x^n}{n!}$$
Input
Hai số ~x~ và ~n~ cách nhau bởi khoảng trắng
Giới hạn:
- ~x~ là số thực, ~-10 \le x \le 10~
- ~n~ là số nguyên dương, ~n \le 10~
Output
Giá trị ~S~ mà bạn tính được làm tròn tới chữ số thập phân thứ 2
Sample
Input #1
2 2
Output #1
4.00
Bình luận
include<bits/stdc++.h>
using namespace std;
int a[1000005], n;
int main() { cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; } sort(a+1, a+n+1); cout << *maxelement(a+2, a+n-1+1) << endl; cout << *minelement(a+2, a+n-1+1) << endl; }
include <bits/stdc++.h>
const int N = 1e5; using namespace std; int a[N + 5], n, m = INT_MAX;
int main() { iosbase::syncwith_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(long long i = 1; i <= n; i++) cin >> a[i]; for(long long i = 1; i <= n; i++) if(a[i] < m) m = a[i]; cout << m << endl; for(long long i = 1; i <= n; i++) if(a[i] == m) cout << i << " "; return 0; }
include <bits/stdc++.h>
const int N = 1e5; using namespace std; int a[N + 5], n, m = INT_MAX;
int main() { iosbase::syncwith_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(long long i = 1; i <= n; i++) cin >> a[i]; for(long long i = 1; i <= n; i++) if(a[i] < m) m = a[i]; cout << m << endl; for(long long i = 1; i <= n; i++) if(a[i] == m) cout << i << " "; return 0; }
include <bits/stdc++.h>
using namespace std; const int N = 1e4 + 5; int a[N], n; int main() { int dau = -1, cuoi = -1; cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) if(a[i] < 0) { dau = i; break; } for(int i = n; i >= 1; i--) if(a[i] < 0) { cuoi = i; break; } cout << dau << " " << cuoi; }
include <bits/stdc++.h>
using namespace std;
int main() { long long a; cin >> a; cout << (a * 5000) - ((a / 6) * 5000); return 0; }
include <bits/stdc++.h>
using namespace std;
int main() { int a, b, c; cin >> a >> b >> c; if(a <= 2 || b <= 2 || c <= 2) { cout << a * b * c; } else { cout << a * b * c - (a - 2) * (b - 2) * (c - 2); } }
include <bits/stdc++.h>
using namespace std;
int main() { long long n; cin >> n; if(n < 2) { cout << "NO"; return 0; } int can = sqrt(n); for(int i = 2; i <= can; i++) { if(n % i == 0) { cout << "NO"; return 0; } } cout << "YES"; return 0; }
include <bits/stdc++.h>
using namespace std;
int main() { long long n; cin >> n; { long long k = sqrt(n); cout << k; } return 0; }
include <bits/stdc++.h>
using namespace std;
int main() { int n; cin >> n; cout << setprecision(2) << fixed << sqrt(n) << endl; }
include <bits/stdc++.h>
using namespace std;
int main() { int a, b, c; cin >> a >> b >> c; int canhconlai;
}
include <bits/stdc++.h>
using namespace std;
int main() { int n; cin >> n; cout << setprecision(2) << fixed << sqrt(n) << endl; }
include <bits/stdc++.h>
using namespace std;
bool snt(long long n) { if(n < 2) return false; for(long long i = 2; i * i <= n; i++) if(n % i == 0) return false; return true; }
int main() { int t; long long a; cin >> t; while(t--) { cin >> a; if(snt(a)) cout << "YES\n"; else cout << "NO\n"; } }
include <bits/stdc++.h>
using namespace std;
int main() { long long n; cin >> n; if(n < 2) { cout << "NO"; return 0; } int can = sqrt(n); for(int i = 2; i <= can; i++) { if(n % i == 0) { cout << "NO"; return 0; } } cout << "YES"; return 0; }
include <bits/stdc++.h>
using namespace std;
int main() { double p1, s1, p2, s2, p3, s3; double a, b, c, u, v, w, p, q, r; cin >> a >> b >> c; cin >> u >> v >> w; cin >> p >> q >> r; p1 = (double)(a + b + c) / 2; s1 = sqrt(p1 * (p1 - a) * (p1 - b) * (p1 - c));
}
include <bits/stdc++.h>
using namespace std;
int main() { int n; cin >> n; cout << setprecision(2) << fixed << sqrt(n) << endl; cout << setprecision(3) << fixed << cbrt(n) << endl; }
include <bits/stdc++.h>
using namespace std;
int main() { long long n; cin >> n; if(n < 2) { cout << "NO"; return 0; } int can = sqrt(n); for(int i = 2; i <= can; i++) { if(n % i == 0) { cout << "NO"; return 0; } } cout << "YES"; return 0; }
include <bits/stdc++.h>
using namespace std;
int main() { long long n; cin >> n; if(n < 2) { cout << "NO"; return 0; } int can = sqrt(n); for(int i = 2; i <= can; i++) { if(n % i == 0) { cout << "NO"; return 0; } } cout << "YES"; return 0; }
FULL AC:
ok cảm ơn bro cho code c++20 nha , tôi cho ông lên điểm đóng góp rồi
include <bits/stdc++.h>
using namespace std;
int solve(int n) { return (n - 1) / 2; }
int main() { int n; cin >> n; cout << solve(n); return 0; }
include <bits/stdc++.h>
using namespace std;
bool solve(long long n) { long long x = sqrt(n); return (x * x == n); }
int main() { long long n; cin >> n;
}
include <bits/stdc++.h>
using namespace std;
int main() { int n, dv, chuc, tram, nghin, t1, t2; cin >> n; dv = n % 10; n /= 10; chuc = n % 10; n /= 10; tram = n % 10; n /= 10; nghin = n % 10; t1 = nghin + tram; t2 = chuc + dv; if(t1 == t2) { cout << "YES"; } else { cout << "NO"; } return 0; }
include <bits/stdc++.h>
using namespace std;
int main() { int n; cin >> n; for(int d = 1; d < n; d++) { if(d % 2 != 0) { cout << d << " "; } } }
include <bits/stdc++.h>
using namespace std;
int main() { int n; cin >> n; cout << "Bang cuu chuong " << n << endl; for(int d = 1; d <= 10; d++) { cout << n << " X " << d << " = " << n * d << endl; } return 0; }
include <bits/stdc++.h>
using namespace std;
int main() { int x, td; cin >> x; if(x <= 100) { td = x * 2000; } else { if(x <= 200) { td = 100 * 2000 + (x - 100) * 3000; } else { if(x <= 300) { td = 100 * 2000 + 100 * 3000 + (x - 200) * 5000; } else { td = 100 * 2000 + 100 * 3000 + 100 * 5000 +(x - 300) * 10000; } } } cout << td; }
include <bits/stdc++.h>
using namespace std;
int main() { int x, td; cin >> x; if(x <= 100) { td = x * 2000; } else { if(x <= 200) { td = 100 * 2000 + (x - 100) * 3000; } else { if(x <= 300) { td = 100 * 2000 + 100 * 3000 + (x - 200) * 5000; } else { td = 100 * 2000 + 100 * 3000 + 100 * 5000 +(x - 300) * 10000; } } } cout << td; }
c++ de hieu
include <bits/stdc++.h>
using namespace std;
int main() { double x; int n; cin >> x >> n; double S = 0;
double k = 1; double j = 1;
for (int i = 1; i <= n; i++) { k = kx;
j =ji;
S += k/j; } cout <<fixed <<setprecision(2)<< S; return 0; }
🗺
cho lời giải nhé các huynh đệ
include <bits/stdc++.h>
using namespace std;
long long factorial(int k) { long long result = 1; for (int i = 2; i <= k; i++) { result *= i; } return result; }
double computeSum(double x, int n) { double sum = 0.0; for (int i = 1; i <= n; i++) { sum += pow(x, i) / factorial(i); } return sum; }
int main() { double x; int n;
}
ko bt
case 2 lag jv mn
Bình luận này đã bị ẩn vì có quá nhiều phản ứng tiêu cực. Nhấn để xem.
chào các bạn
Bình luận này đã bị ẩn vì có quá nhiều phản ứng tiêu cực. Nhấn để xem.
Bình luận này đã bị ẩn vì có quá nhiều phản ứng tiêu cực. Nhấn để xem.
program SumSeries;
uses crt;
function Factorial(n: Integer): Integer; var i, result: Integer; begin result := 1; for i := 1 to n do result := result * i; Factorial := result; end;
function Power(base: Real; exp: Integer): Real; var i: Integer; result: Real; begin result := 1.0; for i := 1 to exp do result := result * base; Power := result; end;
function SumSeries(x: Real; n: Integer): Real; var i: Integer; sum: Real; begin sum := 0.0; for i := 1 to n do sum := sum + (Power(x, i) / Factorial(i)); SumSeries := sum; end;
var x: Real; n: Integer;
begin clrscr;
ReadLn(x);
ReadLn(n);
WriteLn( SumSeries(x, n):0:4);
ReadLn; end.