Can anyone plz suggest errors in my code.Problem : http://codeforces.net/contest/822/problem/D

Правка en1, от akshay_12001, 2017-07-03 22:27:36

include <bits/stdc++.h>

using namespace std;

define MAX 5000001

define modulo 1000000007

long long F[MAX]; bool v[MAX]; long len, sp[MAX];

void Sieve(){ for (long i = 2; i < MAX; i += 2) sp[i] = 2;//even numbers have smallest prime factor 2 for ( long i = 3; i < MAX; i += 2){ if (!v[i]){ sp[i] = i; for (long long j = i; (j*i) < MAX; j += 2){ if (!v[j*i]) v[j*i] = true, sp[j*i] = i; } } } }

int main() { Sieve(); //This function is for pre-processing. This will store smallest prime factor of n in sp[n] long long t,r,l; cin >> t>> l >>r; F[0]=0;F[1]=0;F[2]=1; //Base Cases for (long i = 3; i < MAX; ++i){ F[i] = ((i*(sp[i]-1)/2)%modulo + F[(i/sp[i])]%modulo)%modulo; } long long ans=0, mod=1; for (long i = l; i <= r; ++i) { ans += (mod*F[i])%modulo; ans = ans % modulo; mod=(mod*t)%modulo; } cout<<ans<<endl; return 0; }

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский akshay_12001 2017-07-03 22:27:36 1049 Initial revision (published)