You are viewing a single comment's thread. Return to all comments →
Using Seive C++
using namespace std; using ll = long long; ll mx = 1e5; vector cntDiv(mx+1);
void solve () {
ll n; cin >> n; for (ll i=1; i<=mx; i++){ ll div; if(i%2 == 0) { div = cntDiv[i/2] * cntDiv[i+1]; }else{ div = cntDiv[i] * cntDiv[(i+1)/2]; } if(div>n){ cout << (i*(i+1)) / 2 << "\n"; return; } }
}
int main () {
for (ll i=1; i<=mx; i++) { for (ll j=i; j<=mx; j+=i) { cntDiv[j]++; } } ll t; cin >> t; while ( t--) { solve(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #12: Highly divisible triangular number
You are viewing a single comment's thread. Return to all comments →
Using Seive C++
include
using namespace std; using ll = long long; ll mx = 1e5; vector cntDiv(mx+1);
void solve () {
}
int main () {
}