# JJU-干干

试题 A: 跑步训练

代码:

#include <stdio.h>
#include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) {
int power=10000;
int time;
int redP = 600/60; //每秒减少体力
int addP = 300/60; // 每秒增加体力
int flag=1; //小明先跑,即先消耗,flag=1(奇数),再休息,即增加体力,flag=0 (偶数)
for(time=1;;time++){
if(flag==1){
power-=redP;
}else{
power+=addP;
}
if(power<=0){
break;
}
if(time%60==0){
if(flag==1){
flag=0; // 奇数个60秒后,接下来就是第偶数个60秒,即为增加体力
}else{
flag=1; // 偶数个60秒后,接下来就是第奇数个60秒,即为减少体力
}
}
}
printf("%d",time);
return 0;
}

运行结果:

试题 F: 整除序列

代码:

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) {
ll n;
cin >>n;
while(n!=0){
printf("%lld ",n);
//n >>=1;
n = n/2;
}
return 0;
}

运行结果:

试题 G:解码(程序设计)

题意

代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) {
char a[10000];
int len;
int i,j;
char temp;
gets(a);
len = strlen(a);
for(i=0;i<len;i++){
if((a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='Z')){
printf("%c",a[i]);
temp = a[i];
}
if(a[i]>='2'&&a[i]<='9'){
for(j=0;j<(a[i]-'0'-1);j++){
printf("%c",temp);
}
} }
return 0;
}

运行结果:

试题 I:整数拼接(程序设计)

题意

代码

#include <stdio.h>
#include <stdlib.h>
#include <math.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */
/*代码有待改进,不能满足所有的实例,50%的实例应该可以*/ // 计算数的位数
int cal_len(int n){
int count=0;
while(n!=0){
count++;
n=n/10;
}
return count;
} // 计算10的n次方
int cal_pow(int n){
int sum=1;
int i=0;
for(i=0;i<n;i++){
sum*=10;
}
return sum;
} // 计算拼接后数的和
int cal_sum(long n1,long n2,long len){
long sum1=0;
long sum2=0;
long i=0;
while(n1!=0){
sum1+=(n1%10)*cal_pow(i+len);
i++;
n1=n1/10;
}
i=0;
while(n2!=0){
sum2+=(n2%10)*cal_pow(i);
i++;
n2=n2/10;
}
return (sum1+sum2);
} int main(int argc, char *argv[]) {
long a[10000];
long n,k;
int i,j;
int count=0;
long sum;
int len1,len2; scanf("%d",&n);
scanf("%d",&k);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
} for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
len1 = cal_len(a[i]);
len2=cal_len(a[j]);
sum = cal_sum(a[i],a[j],len2);
if(sum%k==0) count++;
sum = cal_sum(a[j],a[i],len1);
if(sum%k==0) count++;
}
}
printf("%d",count);
return 0;
}

运行结果:

试题 H:走方格(程序设计)

题意



代码:

#include <stdio.h>
#include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) {
int a[40][40];
int i,j;
int m,n;
a[1][1]=1;
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
if(i==1&&j==1){
continue;
}
if(i%2==0&&j%2==0){ // 行为偶,列为偶 ,不符合题意,则置零
a[i][j]=0;
}else{
if(j==1){ // 处于第一列的位置,只能从上面过来
a[i][j]=a[i-1][j];
}else if(i==1){ // 处于第一行的位置,只能从左边过来
a[i][j]=a[i][j-1];
}else{
a[i][j]=a[i-1][j]+a[i][j-1]; // 处于中间的,可从上或从左边来
}
}
}
}
printf("%d",a[n][m]);
return 0;
}

运行结果:

2020年第11届蓝桥杯C/C++B组 第一轮省赛的更多相关文章

  1. 2016 第七届蓝桥杯 c/c++ B组省赛真题及解题报告

    2016 第七届蓝桥杯 c/c++ B组省赛真题及解题报告 勘误1:第6题第4个 if最后一个条件粗心写错了,答案应为1580. 条件应为abs(a[3]-a[7])!=1,宝宝心理苦啊.!感谢zzh ...

  2. 2015年第六届蓝桥杯C/C++B组省赛题目解析

    一.奖券数目 有些人很迷信数字,比如带“4”的数字,认为和“死”谐音,就觉得不吉利.虽然这些说法纯属无稽之谈,但有时还要迎合大众的需求.某抽奖活动的奖券号码是5位数(10000-99999),要求其中 ...

  3. 2015第六届蓝桥杯C/C++ B组

    奖券数目:枚举 有些人很迷信数字,比如带“4”的数字,认为和“死”谐音,就觉得不吉利.虽然这些说法纯属无稽之谈,但有时还要迎合大众的需求.某抽奖活动的奖券号码是5位数(10000-99999),要求其 ...

  4. Java实现 第十一届 蓝桥杯 (高职专科组)省内模拟赛

    有错误的或者有问题的欢迎评论 十六进制数1949对应的十进制数 19000互质的数的个数 70044与113148的最大公约数 第十层的二叉树 洁净数 递增序列 最大的元素距离 元音字母辅音字母的数量 ...

  5. 第九届蓝桥杯C/C++B组省赛感想

    因为做了近三年的初赛题,都对了5题+,所以这次比赛前信心满满,心里想最少水个省二没问题.可我怎么知道今年的套路居然和以前不一样了!一题深搜都没有,想想一周前做的第七届初赛题,10题有3.4题深搜题. ...

  6. 加法变乘法——第六届蓝桥杯C语言B组(省赛)第六题

    原创 加法变乘法 我们都知道:1+2+3+ ... + 49 = 1225现在要求你把其中两个不相邻的加号变成乘号,使得结果为2015 比如:1+2+3+...+10*11+12+...+27*28+ ...

  7. 螺旋折线——第九届蓝桥杯C语言B组(省赛)第七题

    原创 如图p1.png所示的螺旋折线经过平面上所有整点恰好一次. 对于整点(X, Y),我们定义它到原点的距离dis(X, Y)是从原点到(X, Y)的螺旋折线段的长度. 例如dis(0, 1)=3, ...

  8. 移动距离——第六届蓝桥杯C语言B组(省赛)第八题

    原创  问题描述: 移动距离 X星球居民小区的楼房全是一样的,并且按矩阵样式排列.其楼房的编号为1,2,3...当排满一行时,从下一行相邻的楼往反方向排号.比如:当小区排号宽度为6时,开始情形如下: ...

  9. 一步之遥——第七届蓝桥杯C语言B组(国赛)第一题

    原创 一步之遥 从昏迷中醒来,小明发现自己被关在X星球的废矿车里.矿车停在平直的废弃的轨道上.他的面前是两个按钮,分别写着“F”和“B”. 小明突然记起来,这两个按钮可以控制矿车在轨道上前进和后退.按 ...

  10. 递增三元数组——第九届蓝桥杯C语言B组(省赛)第六题

    原创 标题:递增三元组 给定三个整数数组A = [A1, A2, ... AN], B = [B1, B2, ... BN], C = [C1, C2, ... CN],请你统计有多少个三元组(i, ...

随机推荐

  1. HBase对表增查操作 API

    public class HBaseDML { //静态属性 public static Connection conn = HBaseConnection2.conn; //添加数据 public ...

  2. [canvas]ncaught TypeError: Cannot read properties of null (reading 'getContext')

    相信你和我一样是直接复制大佬的js代码(笑) ------------ 主要问题在于:js先加载完了,html才加载,导致js获取不了html的对象 解决办法: 把  <head />  ...

  3. idea插件Tranlation配置有道搜索引擎

    idea配置有道翻译引擎 一.更换翻译引擎原因 由于Google在2022年9月末宣布关闭GoogleTranslate在中国的服务,原本在chrome浏览器和idea上使用的google翻译引擎也不 ...

  4. Unity 获取后缀名

    for(int i = 0;i < files.Length;i++) { if(files[i].Name.EndsWith(".meta")) { continue; } ...

  5. 'xxx' must be unique because it is referenced by a foreign key.

    'xxx' must be unique because it is referenced by a foreign key. 原因:在绑定外键时,对应的外键字段的没有设置成唯一. 说明:在定义字段时 ...

  6. python多线程的问题

    参考:https://stackoverflow.com/questions/20939299/does-python-support-multithreading-can-it-speed-up-e ...

  7. 分治-1-归并排序(Divide and Conquer-1-merge sort)

    #include <stdio.h> #define INFINITY 999999 #define LEN(A) ((sizeof (A)) / (sizeof A[0])) void ...

  8. SpringBoot配置双数据源

    SpringBoot配置双数据源 一.搭建springboot项目 二.添加依赖 <dependencies> <!--web服务--> <dependency> ...

  9. 理解函数调用_arguments对象作为函数参数的别名

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. 前端电商 sku 的全排列算法

    需求 需求描述起来很简单,有这样三个数组: let names = ["iPhone",'iPhone xs'] let colors = ['黑色','白色'] let stor ...