Submission #60544235
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;#define int long long#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);#define nl "\n";#define inf LLONG_MAX#define pb push_back#define pi pair<int, int>#define mp make_pair#define ff first#define ss second#define show(x) cerr << #x << " is " << x << nl;#define showw(x, y) cerr << #x << " is " << x << " " << #y << " is " << y << nl;#define showall(x) cerr << #x << " is "; for (auto i : x) {cerr << i << " ";} cerr << nl;vector<int> gen(int maxim){vector<bool> pos(maxim+1, true);pos[0] = false;pos[1] = false;for (int i=2; i<=sqrt(maxim); i++){if(pos[i]){
#include <bits/stdc++.h> using namespace std; #define int long long #define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define nl "\n"; #define inf LLONG_MAX #define pb push_back #define pi pair<int, int> #define mp make_pair #define ff first #define ss second #define show(x) cerr << #x << " is " << x << nl; #define showw(x, y) cerr << #x << " is " << x << " " << #y << " is " << y << nl; #define showall(x) cerr << #x << " is "; for (auto i : x) {cerr << i << " ";} cerr << nl; vector<int> gen(int maxim){ vector<bool> pos(maxim+1, true); pos[0] = false; pos[1] = false; for (int i=2; i<=sqrt(maxim); i++){ if(pos[i]){ for (int j=i*i; j<=maxim; j+= i){ pos[j] = false; } } } vector<int> p; for (int i=0; i<=maxim; i++){ if(pos[i]) p.pb(i); } return p; } int pow(int x){ int prod = 1; for (int i=0; i<8; i++) prod *= x; return prod; } signed main(){ fastio int n; cin >> n; int base = sqrt(n); vector<int> primes = gen(base); if(primes.empty()){ cout << 0 << nl; return 0; } showall(primes) int bbase = sqrt(base); auto b = upper_bound(primes.begin(), primes.end(), bbase) - primes.begin() - 1; //show(base) if(b<0){ cout << 0 << nl; return 0; } int cnt = 0; for (int i=0; i<=b; i++){ int other = base/primes[i]; auto lb = upper_bound(primes.begin(), primes.end(), other) - primes.begin(); if(lb-1>i) { //showw(primes[i], lb) cnt += (lb-1-i); } } int num = 2; while(pow(num)<=n){ if(find(primes.begin(), primes.end(), num)!=primes.end()) { //show(num) cnt++; } num++; } cout << cnt << nl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 9 Divisors |
User | penguin0 |
Language | C++ 17 (gcc 12.2) |
Score | 400 |
Code Size | 1692 Byte |
Status | AC |
Exec Time | 279 ms |
Memory | 5448 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_01.txt, 00_sample_02.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 1 ms | 3552 KB |
00_sample_02.txt | AC | 277 ms | 5380 KB |
01_test_01.txt | AC | 1 ms | 3428 KB |
01_test_02.txt | AC | 1 ms | 3432 KB |
01_test_03.txt | AC | 1 ms | 3372 KB |
01_test_04.txt | AC | 1 ms | 3444 KB |
01_test_05.txt | AC | 1 ms | 3440 KB |
01_test_06.txt | AC | 163 ms | 4248 KB |
01_test_07.txt | AC | 78 ms | 3668 KB |
01_test_08.txt | AC | 248 ms | 5308 KB |
01_test_09.txt | AC | 263 ms | 5352 KB |
01_test_10.txt | AC | 141 ms | 4244 KB |
01_test_11.txt | AC | 276 ms | 5376 KB |
01_test_12.txt | AC | 151 ms | 4276 KB |
01_test_13.txt | AC | 147 ms | 4120 KB |
01_test_14.txt | AC | 172 ms | 4272 KB |
01_test_15.txt | AC | 269 ms | 5332 KB |
01_test_16.txt | AC | 210 ms | 4288 KB |
01_test_17.txt | AC | 150 ms | 4244 KB |
01_test_18.txt | AC | 135 ms | 4260 KB |
01_test_19.txt | AC | 249 ms | 5260 KB |
01_test_20.txt | AC | 62 ms | 3716 KB |
01_test_21.txt | AC | 1 ms | 3344 KB |
01_test_22.txt | AC | 1 ms | 3376 KB |
01_test_23.txt | AC | 1 ms | 3436 KB |
01_test_24.txt | AC | 277 ms | 5348 KB |
01_test_25.txt | AC | 278 ms | 5360 KB |
01_test_26.txt | AC | 279 ms | 5380 KB |
01_test_27.txt | AC | 276 ms | 5448 KB |
01_test_28.txt | AC | 278 ms | 5360 KB |
01_test_29.txt | AC | 277 ms | 5328 KB |
01_test_30.txt | AC | 261 ms | 5384 KB |
01_test_31.txt | AC | 261 ms | 5388 KB |
01_test_32.txt | AC | 261 ms | 5396 KB |