SDNU-训练赛1-[BCEHIK]

问题虫洞——B:B - Bob HDU - 5878

黑洞内窥:

打表+二分查找(开大一点,不用考虑去重 [打表的我也很。。。。。])

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 1000005*2
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
const ll mod = 1000000007;

ll a[MAXN];
int main()
{
    int n = 0;
    for(int i=0; i<32; ++i)
        for(int j=0; j<25; ++j)
            for(int k=0; k<20; ++k)
                for(int h=0; h<15; ++h)
                {
                    ll s = pow(2, i)*pow(3, j)*pow(5, k)*pow(7, h);
                    if(s > 1000000000) break;
                    else a[n++] = s;
                }
    sort(a, a+n);
    int t;
    cin >> t;
    while(t--)
    {
        ll x;
        scanf("%lld", &x);
        printf("%lld\n", *lower_bound(a, a+n, x));
    }
    return 0;
}



问题虫洞——C:C - Cindy HDU - 5879

黑洞内窥:

题目没有说明n有多大,,,所以读入的n可能有n位。。。。。然后开个一百万 的数组,大于了一百万基本都是某个特定的数了,,,我开是1e-8的数组,,内存超了,,,,

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 1000000
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
const ll mod = 1000000007;

double a[MAXN+20];
int main()
{
    a[1] = 1.0;
    for(int k=2; k<=MAXN; ++k)
    {
        a[k] = a[k-1]+(double)(1.0/k)*(1.0/k);
    }
    string s;
    while(cin >> s)
    {
        int len = s.size(), n=0;
        for(int i=0; i<len; ++i)
        {
            n = n*10 + s[i]-'0';
            if(n > MAXN) break;
        }
        if(n <= MAXN)
            printf("%.5f\n", a[n]);
        else
            printf("%.5f\n", a[MAXN]);
    }
    return 0;
}




问题虫洞——E:E - Edward HDU - 5881

黑洞内窥:

现在有一壶水,体积在[L, R]范围内,现有两个空杯子,现想要把这壶水倒入这两个杯子中去,使得壶中剩余的水的体积<=1,并且两个杯子的体积差<=1;求最少需要到多少次;

光年之外:

找规律

#include  <stdio.h>
#include <iostream>
#include<algorithm>
#include<sstream>
#include      <map>
#include      <set>
#include   <vector>
#include    <queue>
#include    <stack>
#include <stdlib.h>
#include  <cstring>
#include <string.h>
#include   <string>
#include   <math.h>
using namespace std;
typedef long long ll;
#define MAXN 1000005
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
const ll mod = 1000000007;

int main()
{
   ll l, r;
   while(cin >> l >> r)
   {
       if(r <= 1) {puts("0"); continue;}
       if(r == 2) {puts("1"); continue;}
       if(l == 0) cout << (r+1)/2 << '\n';
       else {
        ll tem = (r-l)/2+1;
        if(tem < 2) puts("2");
        else cout << tem << '\n';
       }
   }
    return 0;
}



问题虫洞——H:H - Hydra HDU - 6197

黑洞内窥:

给出n个数,求任意删除k个数之后,剩下的数列是否的非递减或者非递增的数列。

光年之外:

好像写过类似的,,,,从数组的两边求LIS(最长上升子序列),然后用n-ans,如果小于等于k,则是,反正no

#include  <stdio.h>
#include <iostream>
#include<algorithm>
#include<sstream>
#include      <map>
#include      <set>
#include   <vector>
#include    <queue>
#include    <stack>
#include <stdlib.h>
#include  <cstring>
#include <string.h>
#include   <string>
#include   <math.h>
using namespace std;
typedef long long ll;
#define MAXN 1000005
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
const ll mod = 1000000007;

int a[MAXN], dp[MAXN];
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n, k;
        scanf("%d %d", &n, &k);
        for(int i=0; i<n; ++i)
            scanf("%d", &a[i]);
        int cnt=0, ans=0;
        for(int i=0; i<n; ++i)
        {
            int p = upper_bound(dp, dp+cnt, a[i]) - dp;
            if(p == cnt)
            {
                dp[cnt++] = a[i];
                ans = max(ans, cnt);
            }
            else dp[p] = a[i];
        }
        cnt = 0;
        for(int i=n-1; i>=0; --i)
        {
            int p = upper_bound(dp, dp+cnt, a[i]) - dp;
            if(p == cnt)
            {
                dp[cnt++] = a[i];
                ans = max(ans, cnt);
            }
            else dp[p] = a[i];
        }
        if(n-k <= ans) puts("A is a magic array.");
        else puts("A is not a magic array.");
    }
    return 0;
}




问题虫洞——I:I - Isabella HDU - 5477

黑洞内窥:

给你L长的路,在swamp上失去A点能量,在float上会得到B点能量,给出你n个swamp的区间(注意:是区间内,不是点。),问最开始需要携带的最小能量。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 10005
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
const ll mod = 1000000007;

int l[MAXN], r[MAXN];
int main()
{
    int t, ccc=1;
    cin >> t;
    while(t--)
    {
        memset(l, 0, sizeof(l));
        memset(r, 0, sizeof(r));
        int n, a, b, L, sum=0, ans=0;
        scanf("%d %d %d %d", &n, &a, &b, &L);
        l[0] = r[0] = 0;
        for(int i=1; i<=n; ++i)
        {
            scanf("%d %d", &l[i], &r[i]);
            ans = ans+b*(l[i]-r[i-1]) - a*(r[i]-l[i]);
            if(sum > ans) sum = ans;
        }
        sum = -sum;
        printf("Case #%d: %d\n", ccc++, sum);
    }
    return 0;
}




问题虫洞——K:K - Kitty HDU - 4788

黑洞内窥:

每一种单位(XB)到B的转化率是一定的,注意的是,如果你用printf输出的话, 要输出两百分号%%,别问我为什么,你离AC就差一个%,,,所以,以后让我们用cout吧。。。。

你离AC就差一个%。。。。

#include  <stdio.h>
#include <iostream>
#include<algorithm>
#include<sstream>
#include      <map>
#include      <set>
#include   <vector>
#include    <queue>
#include    <stack>
#include <stdlib.h>
#include  <cstring>
#include <string.h>
#include   <string>
#include   <math.h>
using namespace std;
typedef long long ll;
#define MAXN 1000005
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
const ll mod = 1000000007;

string s[9] = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
int main()
{
    int t, cccc= 1;
    cin >> t;
    double mm = 1000.0/1024;
    while(t--)
    {
        string cc, xx;
        cin >> cc;
        int len = cc.size();
        for(int i=0; i<len; ++i)
            if(cc[i] == '[' && cc[i+1] != 'B')
            {
                xx = cc.substr(i+1, 2);
            }
            else if((cc[i] == '[' && cc[i+1] == 'B'))
                xx = cc.substr(i+1, 1);
        int k;
        for(int i=0; i<9; ++i)
            if(s[i] == xx)
                k = i;
        double aaa = pow(mm, k);
        printf("Case #%d: ", cccc++);
        printf("%.2f%%\n", 100*(1.0-aaa));//注意这个百分号,,,,,
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值