Răspuns :
#include <fstream>
#include <vector>
#include <cmath>
using namespace std;
ifstream cin("date.in");
ofstream cout("date.out");
vector <bool> a;
void sieve()
{
int s=sqrt(a.size()-1),p,k;
for (int i=0; i<a.size(); i++) a[i]=false;
for (int x=1; x<=s; x++)
for (int y=1; y<=s; y++)
{
p=4*x*x+y*y;
if (p<a.size() && (p % 12==1 || p % 12 ==5)) a[p]=!a[p];
p-=x*x;
if (p<a.size() && p%12==7) a[p]=!a[p];
p-=2*y*y;
if (x>y && p<a.size() && p % 12 ==11) a[p]=!a[p];
}
for (int i=5; i<=s; i++)
if (a[i])
{
for (p=k=i*i; p<a.size(); p+=k)
a[p]=false;
}
a[2]=true;
a[3]=true;
}
int main()
{
int s=0,p=1,x,y;
cin >> x >> y;
a.resize(y+1);
sieve();
for (int i=x; i<=y; i++)
if (a[i])
{
s+=i;
p*=i;
}
cout << s << '\n' << p;
return 0;
}
#include <vector>
#include <cmath>
using namespace std;
ifstream cin("date.in");
ofstream cout("date.out");
vector <bool> a;
void sieve()
{
int s=sqrt(a.size()-1),p,k;
for (int i=0; i<a.size(); i++) a[i]=false;
for (int x=1; x<=s; x++)
for (int y=1; y<=s; y++)
{
p=4*x*x+y*y;
if (p<a.size() && (p % 12==1 || p % 12 ==5)) a[p]=!a[p];
p-=x*x;
if (p<a.size() && p%12==7) a[p]=!a[p];
p-=2*y*y;
if (x>y && p<a.size() && p % 12 ==11) a[p]=!a[p];
}
for (int i=5; i<=s; i++)
if (a[i])
{
for (p=k=i*i; p<a.size(); p+=k)
a[p]=false;
}
a[2]=true;
a[3]=true;
}
int main()
{
int s=0,p=1,x,y;
cin >> x >> y;
a.resize(y+1);
sieve();
for (int i=x; i<=y; i++)
if (a[i])
{
s+=i;
p*=i;
}
cout << s << '\n' << p;
return 0;
}