CodeForces 70

题目

A题

#include<bits/stdc++.h>
using namespace std;
int n,b,sum;
int main(){
    scanf("%d",&n);
    if (n==0){
        printf("1\n");
        return 0;
    }
    int b=3,sum=1;
    for (int i=1;i<n;++i)
        sum=(sum*b)%1000003;
    printf("%d",sum);
    return 0;
}

B题

难得我能在一群大佬中抢个一血的题

 #include<bits/stdc++.h>
using namespace std;
string s;
vector<int>a;
int n,m,ans;
int main(){
    scanf("%d",&n),m=1;
    getline(cin,s);getline(cin,s);
    for(register int i=0;i<s.size();++i)
        if(s[i]!='?'&&s[i]!='.'&&s[i]!='!')
            ++m;
        else if(m>n){
            printf("Impossible\n");
            return 0;
        }
        else a.push_back(m),m=0;
    for(register int i=0;i<a.size();++i)
        if(m+a[i]+1<=n&&m>0)
            m+=a[i]+1;
        else 
            ++ans,m=a[i];
    printf("%d\n",ans);
    return 0;
}

C题  (siyuan)

#include <bits/stdc++.h>
#define MAXN 100010
using namespace std;
int maxx,maxy,w,b,cd,x;
pair<int,int> f[MAXN],f1[MAXN],ans;
map<pair<int,int>,int> a,b1;
inline pair<int,int> sc(int maxx,int maxy,int w){
	int x=MAXN,y=MAXN;
	for(int i=1,j=0,s=0;i<=maxx;++i){
		a[f[i]]++,s+=b1[f1[i]];
		while(s<w&&j<maxy)
			s+=a[f1[++j]],b1[f[j]]++;
		while(j>0&&s-a[f1[j]]>=w)
			s-=a[f1[j]],b1[f[j]]--,j--;
		if(s>=w&&(1LL*i*j<1LL*x*y))
            x=i,y=j;
	}
	return pair<int,int>(x,y);
}
int main(){
    scanf("%d%d%d",&maxx,&maxy,&w);
	for(int i=1;i<=max(maxx,maxy);i++){
        b=0,x=i;
        while (x) b=b*10+x%10,x/=10;
		cd=__gcd(i,b);
		f[i]=pair<int,int>(i/cd,b/cd);
		f1[i]=pair<int,int>(b/cd,i/cd);
	}
	ans=sc(maxx,maxy,w);
	if(ans.first==100010)
        printf("-1\n");
	else 
        printf("%d %d\n",ans.first,ans.second);
	return 0;
}

D题

517昨天刚刚讲过的题,可我还是不会,我太菜了

#include <bits/stdc++.h>
using namespace std;
const double MIN=1e-8;
const double pi=3.141592653589793238462643383;
int q,i,c,x[10],y[10],xx,yy,x1,x2,yy1,y2;
struct Node{
    double a,b,c,d;
    Node(double x=0,double y=0){
        a=x,b=y,c=sqrt(x*x+y*y);
        if (abs(x)<MIN){
            if (y>MIN)
                d=pi*0.5;
            else d=pi*(-0.5);
        }
        else{
            if (x>MIN)
                d=atan(y/x);
            else{
                if (y>MIN)
                    d=pi+atan(y/x);
                else 
                    d=-pi+atan(y/x); 
            }
        }
    }
}p;
Node operator-(Node a,Node b){
    return Node(a.a-b.a,a.b-b.b);
}
double operator*(Node a,Node b){
    return a.a*b.b-a.b*b.a;
}
bool operator<(Node a,Node b){
    if (a.d==b.d)
        return a.c<b.c;
    else 
        return a.d<b.d;
}
bool operator>(Node a,Node b){
    if (a.d==b.d)
        return a.c>b.c;
    else 
        return a.d>b.d;
}
set<Node>s;
set<Node>::iterator s1;
set<Node>::iterator nex(set<Node>::iterator x){
    x++;
    if (x==s.end())
        return s.begin();
    else 
        return x;
}
set<Node>::iterator pre(set<Node>::iterator x){
    if (x==s.begin())
        x=s.end();
    x--;
    return x;
}
int main(){
    scanf("%d",&q);q-=3;
    for (int i=0;i<3;++i){
        scanf("%d%d%d",&c,&x[i],&y[i]);
        x1=x1+x[i],yy1=yy1+y[i];
    }
    x1/=3.0,yy1/=3.0;
    for (int i=0;i<3;++i)
        s.insert(Node(x[i]-x1,y[i]-yy1));
    while (q--){
        scanf("%d%d%d",&c,&x2,&y2);
        xx=x2-x1,yy=y2-yy1;
        p=Node(xx,yy);
        s1=s.lower_bound(p);
        if(s1==s.end())
            s1=s.begin();
        if (c==1){
            if ((p-*pre(s1))*(*s1-p)>MIN){
                s.insert(p);
                s1=nex(s.find(p));
                while (s.size()>3&&(*s1-p)*(*nex(s1)-*s1)<MIN){
                    s.erase(s1);
                    s1=nex(s.find(p));
                }
                s1=pre(s.find(p));
                while (s.size()>3&&(*s1-*pre(s1))*(p-*s1)<MIN){
                    s.erase(s1);
                    s1=pre(s.find(p));
                }
            }
        }
        else {
            if ((p-*pre(s1))*(*s1-p)<MIN)
                printf("YES\n");
            else 
                printf("NO\n");
        }  
    }
    return 0;
}

E题

这题就不放自己的代码了,siyuan小姐姐真的tql%%%

题解

posted @ 2019-03-10 08:23  Trimsteanima  阅读(101)  评论(4编辑  收藏  举报
Live2D