2012 金华 现场赛

A 水题

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define mod 31536000
#define eps 1e-10
typedef __int64 ll;
struct node
{
    int a,b;
    double id;
}M[500010];
int cmp(node a,node b)
{

    return (long long)a.a*b.b<(long long)b.a*a.b;
}
long long sum,time;
int main()
{
    int i,j,k,n;
    while(scanf("%d",&n)!=EOF)
    {
        if(n==0) break;
        for(i=0;i<n;i++)
        {
            scanf("%d%d",&M[i].a,&M[i].b);
        }
        sort(M,M+n,cmp);
        sum=0;time=0;
        for(i=0;i<n;i++)
        {
            if(M[i].a==0) continue;
            sum+=(long long)(M[i].a+(long long)time*M[i].b);
            sum%=mod;
            time+=(long long)(M[i].a+(long long)time*M[i].b);
            time%=mod;
        }
       //rintf("%lld %lld",time,sum);
        printf("%lld\n",sum%mod);

    }
    return 0;
}


D 枚举每个角度,不知道是不是数据水,枚举1000次就能够了

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

const double PI=acos(-1.0);
const double g = 9.8;
double H,l1,l2,r1,r2;
int n;
double a[300];

int cal(double x){
    int ret = 0;
    for(int i = 0;i<n;i++){
        double vx = a[i]*cos(x);
        double vy = a[i]*sin(x);
        double V = sqrt(2.0*g*H+vy*vy);
        double t = (V-vy)/g;
        double d = 1.0*t*vx;
        if(d<=r2&&d>=l2) return 0;
        if(d<=r1&&d>=l1) ret++;
    }
    return ret;
}

int main(){
        while(scanf("%d",&n)&&n!=0){
            scanf("%lf%lf%lf%lf%lf",&H,&l1,&r1,&l2,&r2);
            for(int i=0;i<n;i++){
                scanf("%lf",&a[i]);
            }

            double add = PI/1000;
            int ans = 0;
            for(double i=-PI/2;i<=PI/2;i+=add){
                ans = max(ans,cal(i));
            }
            printf("%d\n",ans);
        }
}


I 签到题 全部的平方之和

#include <cstdio>
int a[1000];
int main(){
   int n;
   while(scanf("%d",&n)&&n!=0){
     int ans = 0;
    for(int  i = 0;i<n;i++){
        scanf("%d",&a[i]);
        ans += a[i]*a[i];
    }
    printf("%d\n",ans);
   }
}


J 题意没有看 直接例子脑补了一下

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n,m,k;
int p;
int vis1[2222];
int vis2[2222];
char str1[20];
char str2[20];

int main(){
   while(scanf("%d%d%d",&n,&m,&k)&&n+m+k!=0){
      scanf("%d",&p);
      int ans = 0;
      memset(vis1,0,sizeof(vis1));
      memset(vis2,0,sizeof(vis2));
      int a,b;
    while(p--){
        scanf("%s%d%s%d",str1,&a,str2,&b);
        if(str1[0]=='c') {vis1[b]++;ans+=k;}
        else {vis2[a]++,ans+=n;}
    }
    for(int i=1;i<=m;i++){
        ans-=vis1[i]*vis2[i];
    }
    printf("%d\n",n*m*k-ans);
   }
}


K 题意開始看错了 ,应该是在每一次时间结束才转弯,中间过程碰到是不转弯的

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n;
int time;

struct Point
{
	int dir;
	int x,y;
	int s,t;
	void go_next()
    {
	if(dir==0)
	{
		x-=s;
		if(x<1) {x=2-x;dir=2;}
	}
	else if(dir==1)
	{
		y-=s;
		if(y<1) {y=2-y;dir=3;}
	}
	else if(dir==2)
	{
		x+=s;
		if(x>n) {x=2*n-x;dir=0;}
	}
	else
	{
		y+=s;
		if(y>n) {y=n*2-y;dir=1;}
	}
}
}T,J;

int get_dir(char c)
{
	if(c=='N') return 0;
	else if(c=='W') return 1;
	else if(c=='S') return 2;
	else return 3;
}


int main()
{
	while(scanf("%d",&n)&&n!=0)
	{
		T.x=T.y=1;
		J.x=J.y=n;
		char op[10];
		scanf("%s%d%d",op,&T.s,&T.t);
		T.dir=get_dir(op[0]);
		scanf("%s%d%d",op,&J.s,&J.t);
		J.dir=get_dir(op[0]);
		scanf("%d",&time);
		for(int i=1;i<=time;i++)
		{
			T.go_next();
			J.go_next();
			if(T.x==J.x&&T.y==J.y)
			{
				swap(T.dir,J.dir);
				continue;
			}
			if(i%T.t==0) T.dir=(T.dir+1)%4;
			if(i%J.t==0) J.dir=(J.dir+1)%4;
		}
		printf("%d %d\n",T.x,T.y);
        printf("%d %d\n",J.x,J.y);
	}
	return 0;
}


posted @ 2017-07-30 19:47  yfceshi  阅读(123)  评论(0编辑  收藏  举报