پاسخ : آمادگی برای مرحله ۳
کد
#include<iostream>
#include<vector>
#include<fstream>
using namespace std;
long long l[4*1000*1000*10+10],n,k,answer,m;
vector<long long int> aval;
long long int Fi(long long x){
long long ans=x;
for(long long i=0;aval[i]<x;i++){
if(i==aval.size())break;
if(x%aval[i]==0)ans=ans*(aval[i]-1)/aval[i];
}
if(ans==x)ans--;
return ans;
}
int main(){
ifstream fin("out.txt");
for(long long i=0;i<2433654;i++){
fin>>m;
aval.push_back(m);
}
cin>>n>>k;
l[1]=1;
for(long long i=2;i<n;i++)l[i]=l[Fi(i)]+1;
for(long long int i=0;i<aval.size();i++){
if(aval[i]>=n)break;
if(l[aval[i]]==k)answer+=aval[i];
}
cout<<answer<<endl;
cin>>n;
}