Số gần hoàn hảo
View as PDF
Submit solution
Points:
0.01 (partial)
Time limit:
1.0s
Memory limit:
256M
Input:
GHH.INP
Output:
GHH.OUT
Author:
Problem type
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch
Một số nguyên dương ~A~ được gọi là số "gần hoàn hảo" nếu thỏa mãn điều kiện: ~2 \times A \le K~, với ~K~ là tổng các ước số của ~A~.
Ví dụ: ~12~ là một số "gần hoàn hảo" vì ~2 \times 12 \lt 1 + 2 + 3 + 4 + 6 + 12~.
Yêu cầu: Cho một dãy số nguyên dương, hãy in ra các số "gần hoàn hảo".
Input
Vào từ file GHH.INP có cấu trúc như sau:
Dòng đầu tiên chứa số nguyên dương ~N~ (~0 \lt N \le 10^4~).
~N~ dòng tiếp theo, mỗi dòng là một số nguyên dương có giá trị không vượt quá ~10^6~.
Output
Ghi ra file GHH.OUT gồm:
Dòng đầu tiên ghi số lượng số "gần hoàn hảo".
Các dòng tiếp theo, mỗi dòng ghi một số "gần hoàn hảo", số gặp trước thì viết trước.
Sample Input 1
5
8
16
12
6
7
Sample Output 1
2
12
6

Comments
include<bits/stdc++.h>
include<algorithm>
include<vector>
include<unordered_map>
include<set>
define pb push_back
define endl "\n"
define ll long long
define siu cin.tie(nullptr)->syncwithstdio(false);
using namespace std; ll check(ll n) { ll res = 1;
}
void solve() { ll n; cin >> n; vector<ll>a(n); vector<ll>v; for(ll &x : a) { cin >> x; if(x * 2 <= check(x)) { v.pb(x); } } cout << v.size()<<endl; for(ll x : v) { cout << x <<endl; } } int main() { //freopen("GHH.INP","r",stdin); //freopen("GHH.OUT","w",stdout); siu; solve(); return 0; }
hay
jjj
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.