# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19968 | Namnamseo | 팔찌 (kriii4_V) | C++14 | 1000 ms | 24644 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<cstdio>
#include<bitset>
typedef long long ll;
ll M=int(1e9)+7;
ll pow(ll x,ll y){
if(y==0)return 1;
if(y==1)return x;
ll o=pow(x,y/2);
if(y%2==0)return o*o%M;
else return o*o%M*x%M;
}
ll ans [1000010];
ll phi [1000010];
ll kpow[1000010];
std::bitset<1000010> sieve;
int n,k;
int main(){
scanf("%d%d",&n,&k);
int i,j;
kpow[0]=1; kpow[1]=k; phi[1]=1;
for(i=2; i<=n; ++i){
kpow[i]=kpow[i-1]*k%M;
if(sieve[i]) continue;
// i is prime.
for(j=i; j<=n; j+=i){
sieve[j]=true;
if(phi[j]==0) phi[j]=j;
phi[j] /= i;
phi[j] *= i-1;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |