Phép toán 3
Xem dạng PDF
Mã bài:
gold11
Điểm:
1 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
512M
Dữ liệu vào:
stdin
Dữ liệu ra:
stdout
Tác giả:
Dạng bài
Ngôn ngữ cho phép
Viết chương trình nhập vào hai số tự nhiên a, b. In ra kết quả phép tính: a + b + a * b + a * a
Dữ liệu:
- Dòng thứ nhất ghi số tự nhiên a.
- Dòng thứ hai ghi số tự nhiên b.
Kết quả:
- Đưa ra kết quả a + b + a * b + a * a.
Ví dụ:
| Input | Output |
|---|---|
| 1 2 |
6 |
Bình luận
include <bits/stdc++.h>
using namespace std;
define nmax 1000000
define ll long long
bool nt[nmax + 1]; int F[nmax + 1]; void sang() { fill(nt,nt+nmax+1,true); nt[0]=nt[1]=false; for (int i=2;ii<=nmax;i++) { if (nt[i]) { for(int j=ii;j<=nmax;j+=i) nt[j] =false; } } } bool dx(ll n) { ll a=n; ll b=0; while(n>0) { b=b10+n%10; n/=10; } return a==b; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); sang(); ll a, b; cin>>a>>b; ll ca=sqrt(a); ll cb=sqrt(b); ll c=0; for (ll i=ca;i<=cb;i++) { if(nt[i]&&dx(i)) { ll square= (ll) ii; if(square>=a&&square<=b) { c++; } } }
}
include<bits/stdc++.h>
using namespace std; long long a,b; int main () { iosbase::syncwith_stdio(0); cin.tie(0);cout.tie(0); freopen("a.inp","r",stdin); freopen("a.out","w",stdout); cin>>a>>b; cout<<a + b + a * b + a * a; }