郑轻校赛总结

3个经验(1)把简单题想成难题,不愿动脑,死耗着一道题不放(2)和队友交流太少(3)代码细节没扣仔细

1882: 蛤玮的魔法

题目地址:

思路:用相似求比率,都是泪啊,用三角函数时注意里面要用弧度制

AC代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <cstring>
#include <climits>
#include <cmath>
#include <cctype>
const int inf = 0x3f3f3f3f;//1061109567
typedef long long LL;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
const double pi = 3.1415926;
double xiao = 1e-5;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,a,l;
        scanf("%d%d%d",&n,&a,&l);
        double bi = sin(1.0*(n-2)/(2*n)*pi)*sin(1.0*(n-2)/(2*n)*pi);
        double mian = 1.0 * a * a * n/(4*tan(pi/n));
        int sum = 0;
        while(mian-l>xiao)
        {
            sum++;
            mian *= bi;
        }
        printf("%d\n",sum);
    }
    return 0;
}
1877:打扫教室
题目地址:http://acm.zzuli.edu.cn/zzuliacm/problem.php?id=1877
AC代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <cstring>
#include <climits>
#include <cmath>
#include <cctype>
const int inf = 0x3f3f3f3f;//1061109567
typedef long long LL;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const int maxn = 100010;
using namespace std;
int sum[maxn<<2];
int flag[maxn];
struct node
{
    int left;
    int right;
}a[maxn];
void pushdown(int l,int r,int rt)
{
    if(l == r) return;
    sum[rt<<1] += sum[rt];
    sum[rt<<1|1] += sum[rt];
    int m = (l + r) >> 1;
    pushdown(lson);
    pushdown(rson);
    sum[rt] = min(sum[rt<<1],sum[rt<<1|1]);
}
void build(int l,int r,int rt)
{
    sum[rt] = 0;
    if(l == r) return;
    int m = (l+r)>>1;
    build(lson);
    build(rson);
}
void update(int L,int R,int l,int r,int rt)
{
    if(l >= L && r <= R)
    {
        sum[rt] += 1;
        return;
    }
    int m = (l + r)>>1;
    if(L <= m) update(L,R,lson);
    if(R > m) update(L,R,rson);
}
int query(int L,int R,int l,int r,int rt)
{
    if(l >= L && r <= R) return sum[rt];
    int m = (l + r) >> 1;
    int ans = 3;
    if(L <= m) ans = min(ans,query(L,R,lson));//注意这里不能直接return,用min函数啊,不是max函数啊
    if(R > m) ans = min(ans,query(L,R,rson));
    return ans;
}
int main()
{
    int t,n,m;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&m);
        build(1,n,1);
        int left,right;
        for(int i=1; i<=m; i++)
        {
            scanf("%d%d",&left,&right);
            update(left,right,1,n,1);
            a[i].left = left;
            a[i].right = right;
        }
        pushdown(1,n,1);
        int sum = 0;
        for(int i=1; i<=m; i++)
        {
            if(query(a[i].left,a[i].right,1,n,1) >= 2)
                flag[sum++] = i;
        }
        if(sum == 0)
            printf("0\n");
        else
        {
            printf("%d\n%d",sum,flag[0]);
            for(int i=1; i<sum; i++)
                printf(" %d",flag[i]);
            printf("\n");
        }
    }
    return 0;
}
大神地址:http://blog.csdn.net/qq_32680617/article/details/51204232
他直接传到最下面不用标记,有时间写一下标记的

你可能感兴趣的:(郑轻校赛总结)