BOJ 2014新生暑假个人排位赛11 整合

A. 小妹妹个数



桶分+素数筛的乱搞做法, 用纯数学的方法wa了....

待补




B. 田田背课文



我会说再次用qsort水过去了么→_→

随机数据简直卡不掉这个方法

代码和前一场的很相似就不贴了...




C. 小妹妹采蘑菇



数学 概率

很容易推出每一有效步的期望步数为n/i

加和即为答案

居然交了一发4位小数的版本...前一天没睡好...


#include <cstdio>
#include <cstdlib>

#define rep(i,m,n) for(int i=(m);i<=(n);i++)
 
/*author birdstorm*/
using namespace std;

int main()
{
    int n;
    while(~scanf("%d",&n)){
        double ans=0;
        rep(i,1,n)
            ans+=(double)n/(double)i;
        printf("%.6f\n",ans);
    }
    return 0;
}



D. 焦级长的激光炮



二分图+KM算法

待补




E. 小妹妹去划船



模拟水题...

别手贱就行


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <climits>
 
#define MAXN 1000005
#define eps 1e-5
#define MOD 1000000009
#define INF 1000000009
 
#define test
 
#define For(i,m,n) for(int i=(m);i<(n);i++)
#define vecfor(iter,a) for(vector<int>::iterator iter=a.begin();iter!=a.end();iter++)
#define rep(i,m,n) for(int i=(m);i<=(n);i++)
#define LL long long
 
/*author birdstorm*/
using namespace std;
const double pi=acos(-1.0);

char str[MAXN];
int main()
{
    int t;
    int n, m;
    int x1, x2, y1, y2;
    while(~scanf("%d%d%d%d%d",&n,&x1,&y1,&x2,&y2)){
        scanf("%s",str);
        int ansx=0, ansy=0;
        bool right, left, up, down;
        right=left=up=down=false;
        if(x1<x2) ansx=x2-x1, right=true;
        else if(x1>x2) ansx=x1-x2, left=true;
        if(y1<y2) ansy=y2-y1, up=true;
        else if(y1>y2) ansy=y1-y2, down=true;
        int len=strlen(str);
        bool found=false;
        int cnt=0;
        For(i,0,len){
            cnt++;
            if(str[i]=='S'&&down) ansy--;
            if(str[i]=='N'&&up) ansy--;
            if(str[i]=='E'&&right) ansx--;
            if(str[i]=='W'&&left) ansx--;
            if(ansx==0&&ansy==0){
                found=true;
                printf("%d\n",cnt);
                break;
            }
        }
        if(!found) printf("-1\n");
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值