Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <cmath>
- using namespace std;
- ifstream f("cufar.in");
- ofstream g("cufar.out");
- int main()
- {
- long long v,n,i,j,x,y,ok,s=0,ciur[1000],k,m;
- f>>v;
- f>>n;
- ciur[1]=2; k=3; m=1;
- while(k<=1000)
- {
- ok=0;
- for(j=1;(j<=m)&&(ok==0);j++)
- if(k%ciur[j]==0)
- ok=1;
- if(ok==0) {m++; ciur[m]=k;}
- k=k+2;
- }
- for(i=1;i<=n;i++)
- {
- f>>x>>y;
- ok=0;
- for(j=1;(j<=m)&&(ok<y)&&(ciur[j]<=sqrt(x));j++)
- if(x%ciur[j]==0)
- {ok++;
- while(x%ciur[j]==0)
- x=x/ciur[j];
- }
- if(ok==y)
- s=s+ciur[j-1];
- if((x!=1)&&(ok<y)) {ok++; s=s+x;}
- }
- g<<s;
- f.close();
- g.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement