Задача А автор Глембоцький Владислав
using namespace std;
/* Constants begin */
const long long inf = 1e18+7;
const long long mod = 1e9+7;
const double eps = 1e-10;
const double PI = 2*acos(0.0);
const double E = 2.71828;
/* Constants end */
/* Defines begin */
#define pb push_back
#define mp make_pair
#define ll long long
#define F first
#define S second
#define forn(i,n) for (ll (i)=0;(i)<(ll)(n);(i)++)
#define ford(i,n) for (ll (i)=(n)-1;(i)>=(ll)0;(i)--)
/* Defines end */
ll se[100005] = { 1, 1 }, sum[100005] ;
int main(void) {
/* #ifndef ONLINE_JUDGE
freopen("input.txt","rt",stdin);
freopen("output.txt","wt",stdout);
#endif */
ll n, m, a, b ;
cin >> n >> m >> a >> b ;
for(ll i = 2; i < 100005; i++) {
if( !se[i] ) {
for(ll j = 2 * i; j < 100005; j += i) {
se[j] = 1 ;
}
}
sum[i] = sum[i-1] + !se[i] ;
}
if(n > m) swap(n,m) ;
if(a > b) swap(a,b) ;
if( sum[m] - sum[n-1] > sum[b] - sum[a-1] ) {
for(ll i = n; i <= m; i++)
if( !se[i] ) cout << i << " " ;
cout << endl ;
} else {
for(ll i = a; i <= b; i++)
if( !se[i] ) cout << i << " " ;
cout << endl ;
}
return 0 ;
}
Задача В автор Савчук Владислав
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string smax,smin;
int m,smmax=1,smmin=1;
bool fl;
int check(string s1, string s2)
{
if (s1.length()-1>s2.length()-1) return 1;
if (s1.length()-1<s2.length()-1) return 2;
int i;
for (i=0;i<=s1.length()-1;i++) {
if (s1[i]>s2[i]) return 1;
if (s1[i]<s2[i]) return 2;
}
return 0;
}
int main()
{
ifstream cin("numbers.in");
ofstream cout("numbers.out");
string s;
fl=false;
while (!cin.eof())
{
getline(cin,s);
if (s=="") break;
m=1;
if (s[0]=='-') {m=-1; s.erase(0,1);}
while ((s[0]=='0')&&(s.length()-1!=0)) s.erase(0,1);
if (fl==false)
{
smmax=m; smax=s;
smmin=m; smin=s;
fl=true;
}
int t=check(s,smax);
if ((smmax>0)&&(m>0)) if (t==1) {smax=s; smmax=m;}
if ((smmax<0)&&(m>0)) {smax=s; smmax=m;}
if ((smmax<0)&&(m<0)) if (t==2) {smax=s; smmax=m;}
t=check(s,smin);
if ((smmin>0)&&(m>0)) if (t==2) {smin=s; smmin=m;}
if ((smmin>0)&&(m<0)) {smin=s; smmin=m;}
if ((smmin<0)&&(m<0)) if (t==1) {smin=s; smmin=m;}
}
if (smmin<0) cout<<"-";
cout<<smin<<endl;
if (smmax<0) cout<<"-";
cout<<smax<<endl;
}
Задача С автор Шумейко Максим
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include<algorithm>
using namespace std;
double x1[2001],yy[2001],x2[2001],y2[2001],s=0,d,dx,dy,a1,a2,c1,c2,b1,b2,q,w;
int n1;
struct pt {
double x, y;
};
bool cmp (pt a, pt b) {
return a.x < b.x || a.x == b.x && a.y < b.y;
}
vector<pt> a;
bool cw (pt a, pt b, pt c) {
return a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y) < 0;
}
bool ccw (pt a, pt b, pt c) {
return a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y) > 0;
}
void convex_hull (vector<pt> & a) {
if (a.size() == 1) return;
sort (a.begin(), a.end(), &cmp);
pt p1 = a[0], p2 = a.back();
vector<pt> up, down;
up.push_back (p1);
down.push_back (p1);
for (size_t i=1; i<a.size(); ++i) {
if (i==a.size()-1 || cw (p1, a[i], p2)) {
while (up.size()>=2 && !cw (up[up.size()-2], up[up.size()-1], a[i]))
up.pop_back();
up.push_back (a[i]);
}
if (i==a.size()-1 || ccw (p1, a[i], p2)) {
while (down.size()>=2 && !ccw (down[down.size()-2], down[down.size()-1], a[i]))
down.pop_back();
down.push_back (a[i]);
}
}
a.clear();
for (size_t i=0; i<up.size(); ++i)
a.push_back (up[i]);
for (size_t i=down.size()-2; i>0; --i)
a.push_back (down[i]);
}
void output(const vector<pt> &a)
{
double res = 0;
for (int i=2;i<a.size();i++)
res+=((a[0].x-a[i-1].x)*(a[i].y-a[i-1].y)-(a[i].x-a[i-1].x)*(a[0].y-a[i-1].y))/2;
printf("%0.10f",fabs(res));
}
int main()
{
freopen("area.in","r",stdin);
freopen("area.out","w",stdout);
cin>>n1;
for (int i=1;i<=n1;i++) cin>>x1[i]>>yy[i]>>x2[i]>>y2[i];
for (int i=1;i<n1;i++)
for (int j=i+1;j<=n1;j++)
{
pt s;
a1=y2[i]-yy[i];b1=x1[i]-x2[i];c1=yy[i]*(x2[i]-x1[i])-x1[i]*(y2[i]-yy[i]);
a2=y2[j]-yy[j];b2=x1[j]-x2[j];c2=yy[j]*(x2[j]-x1[j])-x1[j]*(y2[j]-yy[j]);
dx=-c1*b2+b1*c2;
dy=-a1*c2+c1*a2;
d=a1*b2-b1*a2;
s.x=dx/d;
s.y=dy/d;
a.push_back(s);
}
convex_hull(a);
output(a);
}