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;
}

版权声明:都是兄弟,请随意转载,请注明兄弟是谁

时间: 2024-08-27 02:48:57

2012 金华 现场赛的相关文章

hdu 4465 Candy 2012 成都现场赛

1 /** 2 对于大数的很好的应用,,缩小放大,,保持精度 3 **/ 4 #include <iostream> 5 #include <cmath> 6 #include <algorithm> 7 #include <cstdio> 8 using namespace std; 9 10 int main() 11 { 12 double n,p; 13 int cnt =1; 14 while(cin>>n>>p){ 15

Go Deeper(2010成都现场赛题)(2-sat)

G - Go Deeper Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Description Here is a procedure's pseudocode: go(int dep, int n, int m) begin output the value of dep. if dep < m and x[a[dep]] + x[b[dep]] != c[dep] then go(dep +

2012金华邀请赛

模拟赛链接 A 第一个水题 要知道units digit的意思  (个位数) 有一点点小繁琐. 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<stdlib.h> 6 #include<cmath> 7 using namespace std; 8 #define N 35 9 int a[N],

HDU 4821 杭州现场赛:每个片段字符串哈希比较

I - String Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4821 Description Given a string S and two integers L and M, we consider a substring of S as "recoverable" if and only if (i) I

13杭州区域赛现场赛Rabbit Kingdom(树状数组+离线)

题意:给你一个长度数列,再给你m个询问(一个区间),问你在这个区间里面有多少个数与其他的数都互质. 解题思路:你看这种类型的题目都可以肯定这是 离线+树状数组(线段树).主要就是他的更新信息.这里我的处理是先把1-200000(每个数的范围)数里面所有的质因子求出来.然后从后往前遍历数组.会出现以下几种情况 1.a[k]的质因子在后面出现过而[更新标记] 和[被更新标记] 都为假 2.a[k]的质因子在后面出现过的那个位置 I   [更新标记]为 真 . 3.a[k]的质因子在后面出现过且那个位

【解题报告】牡丹江现场赛之ABDIK ZOJ 3819 3820 3822 3827 3829

那天在机房做的同步赛,比现场赛要慢了一小时开始,直播那边已经可以看到榜了,所以上来就知道A和I是水题,当时机房电脑出了点问题,就慢了好几分钟,12分钟才A掉第一题... A.Average Score 题目大意:给定A序列和B序列,长度分别是n和m,告诉你A序列中的n-1个数和B序列的m个数,求剩下的那个A序列中的数满足:将这个数从A序列移除,然后添加到B序列,使得A序列的平均值变小,B序列的平均值变大.求这个数的取值范围(是整数) 解题思路:求出A序列剩下的n-1个数的平均值,和B序列的平均值

HDUOJ-------2493Timer(数学 2008北京现场赛H题)

Timer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 445    Accepted Submission(s): 90 Problem Description Recently, some archaeologists discovered an ancient relic on a small island in the Pa

HDU 4791 Alice&#39;s Print Service (2013长沙现场赛,二分)

Alice's Print Service Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1855    Accepted Submission(s): 454 Problem Description Alice is providing print service, while the pricing doesn't seem to

HDU 4791 Alice&#39;s Print Service(2013长沙区域赛现场赛A题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4791 解题报告:打印店提供打印纸张服务,需要收取费用,输入格式是s1 p1 s2 p2 s3 p3...表示打印区间s1到s2张纸的单价是p1,打印区间s2 到s3的单价是p2....最后是sn到无穷大的单价是pn,让你求打印k张纸的总费用最少是多少?有m次查询. 因为s1*p1 > s2 * p2 > s3*p3......,很显然,加入k所在的那个区间是第x个区间,那么最低费用要么是k * p