Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <fstream>
- using namespace std;
- unsigned long a[1000001],b[1000001],i;
- fstream f("cufar.in",ios::in);
- ofstream g("cufar.out");
- int main()
- {
- unsigned long n,k,p,nr,cart,i,nrd;
- f>>p;
- if (p==1)
- {
- unsigned long d,eprim;
- f>>n;
- for (i=1;i<=n;i++)
- {
- f>>cart>>k; eprim=1;nrd=0;
- for (nr=2;nr<=cart/2;nr++)
- {
- for (d=2;d<sqrt(nr);d++)
- if (nr%d==0)
- eprim=0;
- if (eprim&&cart%nr==0)
- nrd++;
- if (nrd==k) {
- g<<nr<<"\n";
- break;}
- }
- }
- }
- else
- {
- unsigned long d,eprim,S=0;
- f>>n;
- for (i=1;i<=n;i++)
- {
- f>>cart>>k; eprim=1;nrd=0;
- for (nr=2;nr<=cart/2;nr++)
- {
- for (d=2;d<sqrt(nr);d++)
- if (nr%d==0)
- eprim=0;
- if (eprim&&cart%nr==0)
- nrd++;
- if (nrd==k) {
- S+=nr;
- // g<<S;
- break;}
- }
- }
- g<<S;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement