牛客网NOIP赛前集训营-普及组(第四场)

版权声明:转就转吧~~记得声明噢~~ https://blog.csdn.net/Soul_97/article/details/82952240

https://www.nowcoder.com/acm/contest/167#question

A 逻辑

原谅我的代码这么长。。

#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e6 + 5;
const int M = 5e5 + 5;

int main()
{
    int n;
    cin >> n;

    int t = n - 5000;
    int sum = 0;

    if(t >= 3000){

        sum += 90;
        if(t >= 12000){

            sum += 9000 * 0.1;

            if(t >= 25000){
                sum += 13000 * 0.2;

                if(t >= 35000){
                    sum += 10000 * 0.25;

                    if(t >= 55000){

                        sum += 20000 * 0.3;

                        if(t >= 80000){

                            sum += 25000 * 0.35;
                            sum += (t - 80000) * 0.45;

                        }else
                            sum += (t - 55000) * 0.35;

                    }else
                        sum += (t - 35000) * 0.3;

                }else
                    sum += (t - 25000) * 0.25;

            }else
                sum += (t - 12000) * 0.2;
        }
        else
            sum += (t - 3000) * 0.1;

    }else if(t >= 0){
        sum += t * 0.03;
    }

    cout << n - sum << endl;

    return 0;
}

B题 

学会了printf一种输出小数的方式 printf("%.*lf",n,x);   n是n位小数,x是double 结果

#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e6 + 5;
const int M = 5e5 + 5;

int main()
{
    int n;
    cin >> n;

    double r = 1;

    r = pow(0.5,n);

    printf("%.*f\n",n,r);
    return 0;
}

C题太长了。。没看

D题规律题

include<bits/stdc++.h>
using namespace std;
long long n,mod=10007,p[10009]={1,1,2};
int main()
{
    string a;
    cin>>a;
    for(int i=0;i<a.length();i++)
    n=(n*10+a[i]-'0')%10006;
    for(int i=3;i<=n;i++)
    p[i]=(2*p[i-1]+p[i-3])%mod;
    cout<<p[n]<<endl;
}

猜你喜欢

转载自blog.csdn.net/Soul_97/article/details/82952240