ap数
This commit is contained in:
parent
f306443f78
commit
7755423390
|
@ -0,0 +1,3 @@
|
|||
# 标题
|
||||
|
||||
* 内容
|
|
@ -0,0 +1 @@
|
|||
#
|
Binary file not shown.
|
@ -0,0 +1,33 @@
|
|||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
cin >> n;
|
||||
int a[1001] = { 0 };
|
||||
for (int i = 1; i <= n; i++) {
|
||||
int len = sqrt(i);
|
||||
for (int j = 1; j <= len; j++) {
|
||||
if (i / j == 0) {
|
||||
break;
|
||||
}
|
||||
if (i % j == 0) {
|
||||
a[i] += 2;
|
||||
if (j == i/j) {
|
||||
a[i]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int ans = 0;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
//cout << i << " " << a[i] << "\n";
|
||||
if (a[ans] < a[i]) {
|
||||
//cout << "\n";
|
||||
ans = i;
|
||||
}
|
||||
}
|
||||
cout << ans;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
10
|
|
@ -0,0 +1 @@
|
|||
20
|
|
@ -0,0 +1 @@
|
|||
50
|
|
@ -0,0 +1,18 @@
|
|||
## z:\Chao\src\2757_num_apbit\test\in.txt
|
||||
2020/05/01 ÖÜÎå 19:19:47.36
|
||||
6
|
||||
-----------------------------------------------
|
||||
Process exited after 160 ms with return value 0
|
||||
|
||||
## z:\Chao\src\2757_num_apbit\test\in2.txt
|
||||
2020/05/01 ÖÜÎå 19:19:47.36
|
||||
12
|
||||
-----------------------------------------------
|
||||
Process exited after 100 ms with return value 0
|
||||
|
||||
## z:\Chao\src\2757_num_apbit\test\in3.txt
|
||||
2020/05/01 ÖÜÎå 19:19:47.36
|
||||
48
|
||||
-----------------------------------------------
|
||||
Process exited after 90 ms with return value 0
|
||||
|
Loading…
Reference in New Issue