蓝桥杯训练 3

1508: [蓝桥杯2020初赛] 门牌制作

内存限制:256 MB时间限制:1 S标准输入输出

题目描述

小蓝要为一条街的住户制作门牌号。
这条街一共有2020 位住户,门牌号从1 到2020 编号。
小蓝制作门牌的方法是先制作0 到9 这几个数字字符,最后根据需要将字符粘贴到门牌上,例如门牌1017 需要依次粘贴字符1、0、1、7,即需要1 个字符0,2 个字符1,1 个字符7。
请问要制作所有的1 到2020 号门牌,总共需要多少个字符2?

 #include<iostream>
#include <istream>
#include<algorithm>
#include <cstring>
#include <queue>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <stack>
#include <sstream>
#include <stdlib.h>
#include <iomanip>
#include <utility>
//#define int long long
using namespace std;
//#define INF 0x3f3f3f3f
//int gcd(int a,int b)
//{
//    return b == 0 ? a : gcd(b, a % b);
//}
int a[10];
int main()
{
    for (int i = 1; i <= 2020; i++)
    {
        int num = i;
        while (num > 0)
        {
            a[num % 10]++;
            num /= 10;
        }
    }
    cout << a[2];
}

1509: [蓝桥杯2020初赛] 既约分数

内存限制:256 MB时间限制:1 S标准输入输出

题目描述

如果一个分数的分子和分母的最大公约数是1,这个分数称为既约分数。
例如34,52,18,7143​,25​,81​,17​都是既约分数。
请问,有多少个既约分数,分子和分母都是1 到2020 之间的整数(包括1和2020)?

#include<iostream>
#include <istream>
#include<algorithm>
#include <cstring>
#include <queue>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <stack>
#include <sstream>
#include <stdlib.h>
#include <iomanip>
#include <utility>
//#define int long long
using namespace std;
//#define INF 0x3f3f3f3f
int gcd(int a,int b)
{
    return b == 0 ? a : gcd(b, a % b);
}
int a[10];
int main()
{
    int cnt = 0;
    for (int i = 1; i <= 2020; i++)
    {
        for (int j = i; j <= 2020; j++)
        {
            if (gcd(i, j) == 1)
                cnt += 2;
        }
    }
    cout << cnt-1;
}

//画个图找一下规律

1510: [蓝桥杯2020初赛] 蛇形填数

内存限制:256 MB时间限制:1 S标准输入输出

题目描述

如下图所示,小明用从1 开始的正整数“蛇形”填充无限大的矩阵。
126715...35814...4913...1012...11......  1341011...  ​25912...​6813...​714...15......
容易看出矩阵第二行第二列中的数是5。请你计算矩阵中第20 行第20 列的数是多少?

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int sum=1;
    for(int i=1;i<=19;i++)
    sum+=i*4;
    cout<<sum;
}

//找规律

1511: [蓝桥杯2020初赛] 七段码

内存限制:256 MB时间限制:1 S标准输入输出

题目描述

小蓝要用七段码数码管来表示一种特殊的文字。

 


上图给出了七段码数码管的一个图示,数码管中一共有7 段可以发光的二极管,分别标记为a, b, c, d, e, f, g。
小蓝要选择一部分二极管(至少要有一个)发光来表达字符。在设计字符的表达时,要求所有发光的二极管是连成一片的。
例如:b 发光,其他二极管不发光可以用来表达一种字符。
例如:c 发光,其他二极管不发光可以用来表达一种字符。这种方案与上一行的方案可以用来表示不同的字符,尽管看上去比较相似。
例如:a, b, c, d, e 发光,f, g 不发光可以用来表达一种字符。
例如:b, f 发光,其他二极管不发光则不能用来表达一种字符,因为发光的二极管没有连成一片。
请问,小蓝可以用七段码数码管表达多少种不同的字符?

//直接数的

1513: [蓝桥杯2020初赛] 跑步锻炼

内存限制:256 MB时间限制:1 S标准输入输出

题目描述

小蓝每天都锻炼身体。
正常情况下,小蓝每天跑1 千米。如果某天是周一或者月初(1 日),为了激励自己,小蓝要跑2 千米。如果同时是周一或月初,小蓝也是跑2 千米。
小蓝跑步已经坚持了很长时间,从2000 年1 月1 日周六(含)到2020 年10 月1 日周四(含)。
请问这段时间小蓝总共跑步多少千米?

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int day = 0, num;
int fun(int i)
{
    if(i%4 == 0 && i%100 != 0 || i%400 == 0)
    return 1; 
    return 0;
}
int a[15] = {
                 0, 
                 31, 28,
                 31, 30,
                 31, 30,
                 31, 31,
                 30, 31,
                 30, 31,
            };
int main()
{
    for(int i = 2000; i <= 2021; i++)
    {
        if(fun(i))a[2] = 29;  
        else a[2] = 28;
            for(int j = 1; j <= 12; j++)
                for(int k = 1; k <= a[j]; k++)
                {
                    day += 1;
                    if(k == 1 || num % 7 == 2)day++;     
                    num++;
                    if(i == 2020 && j == 10 && k == 1)
                    {
                        cout << day;
                        return 0;
                    }
                }        
    }
    return 0;
}

//考虑闰年和2月

1522: [蓝桥杯2020初赛] 成绩统计

内存限制:256 MB时间限制:1 S标准输入输出

小蓝给学生们组织了一场考试,卷面总分为100 分,每个学生的得分都是一个0 到100 的整数。
如果得分至少是60 分,则称为及格。如果得分至少为85 分,则称为优秀。
请计算及格率和优秀率,用百分数表示,百分号前的部分四舍五入保留整数。

输入格式

输入的第一行包含一个整数n,表示考试人数。
接下来n 行,每行包含一个0 至100 的整数,表示一个学生的得分。

#include<iostream>
#include <istream>
#include<algorithm>
#include <cstring>
#include <queue>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <stack>
#include <sstream>
#include <stdlib.h>
#include <iomanip>
#include <utility>
//#define int long long
using namespace std;
//#define INF 0x3f3f3f3f
int gcd(int a,int b)
{
    return b == 0 ? a : gcd(b, a % b);
}
int main()
{
    int n,m, num;
    int cnt1 = 0, cnt2 = 0;
    cin >> n;
    m = n;
    while (n--)
    {
        cin >> num;
        if (num >= 60)
            cnt1++;
        if (num >= 85)
            cnt2++;
    }
    double jige = cnt1 * 1.0 / m,youxiu = cnt2 * 1.0 / m;
    int a = jige * 1000,b=youxiu*1000;
    if (a % 10 < 5)
        a /= 10;
    else
        a = (a / 10 + 1);
    if (b % 10 <  5)
        b /= 10;
    else
        b = (b / 10 + 1);
    cout <<  a << "%" << endl << b << "%";
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值