2021.1.11寒假打卡Day8

2018黑龙江省赛 Similar Strings Similar Strings 时间限制: 1 Sec  内存限制: 128 MB 提交: 18  解决: 9 [提交] [状态] [讨论版] [命题人:admin] 题目描述 Putting two similar strings together will create a very strong power that can quake the earth into parts a... 阅读详情

哈尔滨学院2021ACM冬令营Day2(20级)

The puzzle

Problem Description
Kayaking is playing a puzzle game containing n different blocks. He marks the blocks with integers from 1 to n, which show the blocks’ original positions. Each time he can exchange two blocks and he wants to know how many times he needs at least to restore the puzzle.

Input
The input starts with one line contains exactly one positive integer which is the number of test cases.
Each test case contains two lines.

The first line contains an integer, which indicates the number of puzzle pieces.

The second line contains n different integers, the i-th number means the mark of the block in the i-th position.

Output
For each test case, output one line with one number represents the minimum operations.

Sample Input

2
4
2 3 4 1
4
2 1 4 3

Sample Output

3
2

Hint
1 ≤ T ≤ 20
1 ≤ n ≤ 100000

selection sort

#include<iostream>
using namespace std;

int a[100005];

int main(){
	int t,n,cnt,i,j,minj;
	cin>>t;
	while(t--){
		cin>>n;
		cnt=0;
		for(i=0;i<n;i++) cin>>a[i];
		for(i=0;i<n;i++){
			minj=i;
			for(j=n-1;j>i;j--){
				if(a[j]<a[minj]) minj=j;
			}
			if(minj==i) continue;
			else{
				int s=a[j];
				a[j]=a[minj];
				a[minj]=s;
				++cnt;
			}
		}
		cout<<cnt<<endl;
	} 
	return 0;
}

Overflow

Problem Description
Kayaking is a naughty boy and he loves to play water. One day, Kayaking finds a bucket. The bottom area of the bucket is S and the height is H. Initially, there is V volume water in the bucket. What makes Kayaking happy is that there are N cube woods beside the bucket. The side length of the i-th cube woods is L[i] and its density is P[i]. Kayaking wants to put all the cube woods to the bucket. And then he will put a cover at the top of the bucket. But CoffeeDog doesn’t allow unless Kayaking can tell CoffeeDog the height of the water in the bucket after Kayaking put all the cuboid woods to the bucket. Could you help him?

It is guaranteed that the cube woods aren’t overlapping. And after putting the wood to the bucket, the bottom of the wood is parallel to the bottom of the bucket.

Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.

The first line of each test case contains a single integer N denoting the number of cube woods.

Then comes N line. Each line has two real numbers L[i] and P[i].

The last line contains three integers S, H and V.

Output
For each test cases, print a single line containing one real number—the height of the water in the bucket(the number should be rounded to the second digit after the decimal point).

Sample Input

1
2
1 1.5
1 0.5
5 100 25

Sample Output

5.30

Hint

T ≤ 10
n ≤ 104,P ≤ 6,L ≤ 3,H ≤ 100,L ≤ H
V,S ≤ 107

还好他没有盖上盖子。。。
初中科学:ρ水gh = ρ木v → △h = ρ木L3 / ( ρ水g ) (ρ水 = 1 Kg/m3, g = 10 N/Kg)
ans = (V + Σ△hL2)/S
考虑水漫出来的情况 V / S + Σ△h > H,输出H
题目有点坑……存在比水密度大的木头

为啥我手算样例结果是5.20…

#include<iostream>
using namespace std;

int main() {
	int t,n;
	cin>>t;
	while(t--){
		double d,p,h,s,v,ans,dh=0;
		cin>>n;
		while(n--){
			cin>>d>>p;
			dh+=d*d*d*p/10;
		}
		cin>>s>>h>>v;
		ans=(v+dh*d*d)/s;
		if(ans>=h) printf("%.2lf\n",h);
		else printf("%.2lf\n",ans);
	}
	return 0;
}

Flower

Problem Description
Rabbit loves flowers very much and she plants n pots of flowers in her house. But she never prunes them because she is lazy. So the flowers have different heights and look ugly. One day, Kayaking decides to prune the flowers to make them look beautiful. To make them have equal heights, smart Kayaking has a wonderful idea. Initially, the i-th pot of flower’s height is a[i]. Each time, Kayaking will select n-1 pots of flowers and prune them to make their height subtract 1 with his 49m knife. Exactly, the height of the flowers is at least 1. Now, Kayaking wants to know if it is possible to prune the flowers to make them have equal height. If possible, what is the minimum times he prunes the flowers. Could you tell him?

Input
The input starts with a line contains exactly one positive number T which is the number of test case.

Each test case starts with a line contains a number n indicates the number of flowers.

Then there is a line contains n numbers indicates a[i].

Output
For each test case, print a single line containing one integer—the minimum times Kayaking prunes the flowers, or -1 if it is impossible.

Sample Input

2
5
1 2 2 2 2
5
1 2 2 2 3

Sample Output

1
-1

Hint
T ≤ 10
n ≤ 105
ai ≤ 109

🔗来自巨佬的题解:
逆向思维——裁剪n-1个 相当于 增长保留的那一个
边界考虑——max > Σ(max - a[i])

#include<stdio.h>
using namespace std;

int a[100005];

int main(){
	int n, m, t,max;
    cin >> t;
    while(t -- ){
        scanf("%d", &n);
        for(int i = 1; i <= n; ++ i){
            scanf("%d", &a[i]);
            max = max > a[i] ? max : a[i];
        }
        int sum = 0;
        for(int i = 1; i <= n; ++ i)
            sum += max - a[i];
        if(sum >= max) puts("-1");
        else printf("%d\n", sum);
    }
    return 0;
}

A Count Task

Problem Description
Count is one of WNJXYK’s favorite tasks. Recently, he had a very long string and he wondered that how many substrings which contains exactly one kind of lowercase in this long string. But this string is so long that he had kept counting for several days. His friend Kayaking wants to help him, so he turns to you for help.

Input
The input starts with one line contains exactly one positive integer T which is the number of test cases.

Each test case contains one line with a string which you need to do a counting task on.

Output
For each test case, output one line containing “y” where y is the number of target substrings.

Sample Input

3
qwertyuiop
qqwweerrttyyuuiioopp
aaaaaaaaaa

Sample Output

10
30
55

Hint
1 ≤ T ≤ 20
1 ≤ len(string) ≤ 105
1 ≤ ∑len(string) ≤ 105
Strings only contain lowercase English letters.

#include<stdio.h>

int main(){
	char c;
	int t;
	scanf("%d", &t);
	c=getchar();
	while(t--){
		bool flag[200]={true};
		int cnt=0;
		while((c=getchar())!='\n'){
			flag[c]=1;
		}
		for(int i=97;i<=122;i++)
			if(flag[i]) ++cnt;
		printf("%d\n",cnt);
	}
	return 0;
}

Financial Management

Description

Larry graduated this year and finally has a job. He’s making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to grab hold of his financial portfolio and solve his financing problems. The first step is to figure out what’s been going on with his money. Larry has his bank account statements and wants to see how much money he has. Help Larry by writing a program to take his closing balance from each of the past twelve months and calculate his average account balance.

Input
The input will be twelve lines.
Each line will contain the closing balance of his bank account for a particular month.
Each number will be positive and displayed to the penny.
No dollar sign will be included.

Output

The output will be a single number, the average (mean) of the closing balances for the twelve months. It will be rounded to the nearest penny, preceded immediately by a dollar sign, and followed by the end-of-line. There will be no other spaces or characters in the output.

Sample Input

100.00
489.12
12454.12
1234.10
823.05
109.20
5.27
1542.25
839.18
83.99
1295.01
1.75

Sample Output

$1581.42

calculate average, even dont need to plus 0.005

#include<stdio.h>

int main(){
	double a,ave=0;
	for(int i=1;i<=12;i++){
		scanf("%lf",&a);
		ave+=a;
	}
	ave=ave/12.0;
	printf("$%.2lf\n",ave);
	return 0;
}

1046 A^B Mod C

给出3个正整数A B C,求A^B Mod C。
例如,3 5 8,3^5 Mod 8 = 3。

输入
3个正整数A B C,中间用空格分隔。(1 <= A,B,C <= 109)

输出
输出计算结果

输入样例

3 5 8

输出样例

3
  • pow()函数在math.h这个库里
  • pow()函数的声明:double pow(double x, double y) (注意数据类型)
#include<stdio.h>
#include<math.h>

int main(){
	double a,b;
	int c;
	scanf("%lf%lf%d",&a,&b,&c);
	printf("%d\n",(int)pow(a,b)/c);
	return 0;
}

Watermelon

One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.

Pete and Billy are great fans of even numbers, that’s why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that’s why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.

Input
The first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys.

Output
Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case.

Examples
input

8

output

YES

Note
For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos).

cf 第一简单题:判断是否是大于2的整数

#include<stdio.h>

int main()
{
	int a;
	scanf("%d",&a);
	if(a>2&&a%2==0)
		printf("YES");
	else
		printf("NO");
	return 0;
}

Way Too Long Words

Sometimes some words like “localization” or “internationalization” are so long that writing them many times in one text is quite tiresome.

Let’s consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.

This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn’t contain any leading zeroes.

Thus, “localization” will be spelt as “l10n”, and "internationalization» will be spelt as “i18n”.

You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes.

Input
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.

Output
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.

Examples
input

4
word
localization
internationalization
pneumonoultramicroscopicsilicovolcanoconiosis

output

word
l10n
i18n
p43s

寒假打卡Day1 的水题( ̄▽ ̄)

#include<iostream>
#include<string.h>
using namespace std;

int main(){
	char ch[105];
	int t;
	cin>>t;
	while(t--){
		cin>>ch;
		if(strlen(ch)<=10){
			cout<<ch<<endl;
			continue;
		}
		cout<<ch[0]<<strlen(ch)-2<<ch[strlen(ch)-1]<<endl;
	}
	return 0;
} 
2021寒假MISC打卡DAY11 1 1 1 1 1 1 1 1 阅读详情

相关推荐

STM32MP157+AD7606BSTZ四通道IEPE传感器采集方案实战(附完整电路图)

本文详细介绍了基于STM32MP157和AD7606BSTZ的四通道IEPE传感器采集方案,涵盖硬件电路设计、软件驱动开发及系统性能优化。通过精确的恒流源设计和同步采样技术,实现高精度振动信号采集,适用于工业振动监测等应用场景。

weixin_42713608的博客 704

HHTC_学校集训编程题目(10)(个人赛_4)

HHTC_学校集训编程题目(10)(个人赛_4)A - A Count TaskF - Similar StringsG - FlowerH - OverflowJ - The puzzle 记录记录这几天做的题目 其实个人赛已经结束了,组队赛都开始了,太懒,现在才记录 简单题就不记录了,记录一下有点收获的题目 A - A Count Task Count is one of WNJXYK’s ...

A_dmin的博客 755

论文阅读笔记(一)细粒度图像检索

0、参考文献 [1]见微知著 http://geek.csdn.net/news/detail/191718 [2]Xiu-Shen Wei 《Selective Convolutional Descriptor Aggregation for Fine-Grained Image Retrieval》 [3]Lingxi Xie 《Fine-Grained Image Search》 1...

huang2818138的博客 1万+

A - A Count Task HDU - 6480

Count is one of WNJXYK’s favorite tasks. Recently, he had a very long string and he wondered that how many substrings which contains exactly one kind of lowercase in this long string. But this string ...

云乐 381

RV1126平台librga图像旋转裁剪实战

本文详细介绍了在rv1126平台上使用librga库实现图像旋转和裁剪的方法。首先解释了librga的基本概念和关键对象,包括源图像、目标图像和操作参数。随后分步骤说明了初始化设置、缓冲区创建、裁剪区域定义(通过坐标和尺寸参数)以及旋转操作(支持常见角度)。提供了完整的示例代码演示如何组合裁剪和旋转操作,并强调了性能优化、错误处理、格式支持等注意事项。通过硬件加速的librga,可以在rv1126平台上高效完成图像处理任务。

hwmxrhx的博客 1545

Pulpino SoC中挂载AXI从机接口的自定义IP说明

AXI 从机接口挂载 Pulpino SoC 调试Pulpino SoC中挂载AXI从机接口的自定义IP说明PULPion SoC介绍自定义AXI IP挂载IP挂载框图代码修改脚本修改自定义AXI IP调试C语言编写软件调试硬件调试 Pulpino SoC中挂载AXI从机接口的自定义IP说明 本篇文章主要从工程的角度描述了如何将具有AXI从机接口的自定义IP挂载到Pulpino SoC上,其中不涉及到SoC中的任何原理知识。 PULPion SoC介绍 PULPion SoC整体架构如下图所示, PULPi

小陈的芯片学习之路 2211

【HDU 6048 Puzzle】 逆序对 & 思维

PuzzleTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 446 Accepted Submission(s): 242Problem Description A Jigsaw puzzle contains N*M-1 p

楚江枫 573

2023华为od机试C卷【最富裕的小家庭】Python 实现

在一颗树中,每个节点代表一个家庭成员,节点的数字表示其个人的财富值,一个节点及其直接相连的子节点被定义为个小家庭。现给你一颗树,请计算出最富裕的小家庭的财富和。

MISAYAONE的博客 2044

Similar Strings

题目描述 Putting two similar strings together will create a very strong power that can quake the earth into parts and the person who did that can be called the Destroyer of the World. In order to stop th...

weixin_41370251的博客 748

【2026华为OD新规机考】最新套题持续更新【完全原创题解 | 详细考点分类 | 不断更新题目 | 六种主流语言Py+Java+Cpp+C+Js+Go】

可上练习华子OD、大厂真题绿色聊天软件戳od1441了解算法冲刺训练(备注【优快云】否则不通过)

weixin_48157259的博客 508

​热电偶测温电路图(一)​

高精度热电偶测温电路图 此设计概括了提供传感器诊断所必需的抗混叠滤波器和偏置电阻器。此示例还提供了一种新颖的方式,即使用ADS1118上的板载温度传感器完成对系统的冷端补偿。对于热电偶线性化,此设计还提供了一种非常简单的、可以在大多数微控制器上实施的线性算法。 缺点就是太贵。 特性 测量K型热电偶温度 精度1°C 高精度/可重复性0.2°C 包含冷端补偿 包含软件算法 使用ADS111816位ADC(带PGA) 原理图/方框图 热电偶测温电路图(二) OP07构成的高稳定热电

zxm8513优快云博客 2万+

寒假自学打卡

Day 2020.02.12 – 打卡第9天 今日完成任务: 1.毕设实现电容内环控制 2. 雅思口语模考 明日计划: 继续毕设和英语 Day 2020.02.13 – 打卡第10天 今日完成任务: 1.毕设根据师兄的建议修改格式及内容 雅思网课/KEEP健身 明日计划: 继续毕设和英语和健身 Day 2020.02.14 – 打卡第11天 今日完成任务: 1.毕设修改格式/研究三相四线制中线谐...

电力电子&电能质量求交流,加Q164429350 463

基于STM32、HAL库的IP5356M_DBZ_CA快充协议芯片简介及驱动程序设计

IP5356M_BATTERY_LEVEL_25 = 1, /* 电池电量25% */IP5356M_CHARGE_STATE_CHARGE_DONE = 4, /* 充电完成 */IP5356M_CHARGE_STATE_FAST = 2, /* 快速充电 */IP5356M_CHARGE_STATE_NONE = 0, /* 无充电 */IP5356M_CHARGE_STATE_PRE = 1, /* 预充电 *//* 延时1秒 */

corlin6688的博客 1418

2021寒假MISC打卡DAY3

[SWPU2019]Network 得到的 flag 请包上 flag{} 提交。 一道平平无奇的脚本题 63 127 255 通过进制转换联想到00 01 10 11 f = open("attachment.txt", "r") s = '' tmp = '' while 1: num = f.readline() if not num: break if num.rstrip() == '63': tmp = '00' ...

煤矿路口西的博客 775

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

2021.1.17寒假打卡Day13

A - 小心FST! Mia Hossain is a very good competitive programmer & spends his most of the time in programming contest. His wife is very much interested in competitive programming. In her free time she sits beside him & curiously watches how he solves p

Connor的博客 615

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

AcWing寒假每日一题

AcWing寒假每日一题

青少年趣味编程 506

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

2021.1.28寒假打卡Day21

求n个数的最小公倍数 #include<iostream> using namespace std; int gcd(int a,int b){ int r=a%b; if(r==0) return b; else return gcd(b,r); } int nlcm(int a[],int b){ while(b!=1){ a[b-2]=a[b-1]*a[b-2]/gcd(a[b-1],a[b-2]); --b; }

Connor的博客 237

2021寒假MISC打卡DAY4

[GKCTF2020]code obfuscation 压缩包密码是加密过的 得到一张扭曲的二维码,还原得 天天PS我真是:) 扫码得【base(gkctf)】 根据提示,存在压缩包,对图片进行分离,果然得到了。 将明文通过base58加密后得到CfjxaPF,解开 得名为1的文件和flag3.png 图片不知道咋说啥,先处理1里的内容 eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)...

煤矿路口西的博客 517

2021寒假MISC打卡DAY7

[湖南省赛2019]Findme 得到的 flag 请包上 flag{} 提交。 得到五张图片,以此查看二进制,明显的, 5.png末尾得到 I give U a gift:Yzcllfc0lN 2.png中藏着很多.txt 正如我们所知.7z也是压缩包的后缀名之一 直接binwalk -e 2.png,未果 统一替换377A为504B后分离,得1000个txt 随意点开几个,发现内容一致 N0thIng h3re 根据大小或修改日期对这些文件进行排序,得到一个不一样的618.tx...

煤矿路口西的博客 360

2021寒假MISC打卡DAY5

[MRCTF2020]Hello_ misc 得到的 flag 请包上 flag{} 提交。 感谢Galaxy师傅供题。 真实脑洞题 前半部分还是常规操作 得到【flag.rar】【try to restore it.png】 对图片进行lsb解密,分别在red通道和blue通道看到东西 extract后,看到在red为0是藏有一张png 导出,得到 不是【flag.rar】的密码,看来还有压缩包 对图片查看二进制后,手动分离出一个压缩包,命名为【file.zip】叭 利用密码!@#$...

煤矿路口西的博客 416

LeetCode寒假刷题 Day07

文章目录前言一、054 螺旋矩阵1. 题目描述2. 解题思路3. 代码实现二、059 螺旋矩阵 II1. 题目描述2. 解题思路3. 代码实现三、061 旋转链表1. 题目描述2. 解题思路3. 代码实现总结 前言 今天是寒假LeetCode刷题打卡的第七天,继续坚持、继续加油!也希望我的博文能够帮助到大家,若有疑问,可以随时私信Call我! 一、054 螺旋矩阵 1. 题目描述 题号:54 难度:中等 054 螺旋矩阵 给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返

qq_42833339的博客 578

小甲鱼课后作业_【第九讲勤思课后作业】二元一次方程组的解法巩固加油站

☝点击蓝字关注我们二元一次方程组解法巩固|第9讲二元一次方程组解法:核心是消元两种消元方法:代入消元法和加减消元法技巧类解法:系数轮换法和换元法以下为第9讲勤思班作业的视频讲解第九讲的巩固加油站就到这里勤思班的宝宝一定要看下!通知:寒假及春季班次还没缴费的同学记得及时缴费~~不念过去不畏将来THE END关注张老师 数学不掉队金蝉定律微信号 :zxkzjdsj如有问题可公众号或微信联系 ...

weixin_39638305的博客 142

21天掌握Kuikly-OH开源鸿蒙跨平台开发实战

跨平台开发技术通过抽象底层差异实现代码复用,显著提升多端适配效率。以OpenHarmony为代表的物联网操作系统正推动全场景设备开发范式变革,其中Kuikly-OH框架采用TypeScript声明式编程模型,通过虚拟DOM优化和统一API层,可降低33%内存占用并实现一次编写多端运行。这类技术在智能家居控制面板、健康监测应用等场景具有显著优势,特别是需要同时适配手机、平板、智能手表的场景。本次21天训练营系统讲解从环境搭建到性能优化的完整流程,包含分布式设备协同、传感器集成等实战内容,帮助开发者快速切入开源

weixin_34343308的博客 356

AI在大学申请中为何失效?招生逻辑与技术工具的错位解析

大学本科申请本质上是一场基于行为数据与成长语境的可信度验证,而非文本生成任务。其核心机制——整体性评估(Holistic Review)、时间锚定叙事、多源证据链交叉验证——与AI平台依赖模式匹配、批量生成、通用化表达的技术原理存在根本性冲突。当AI试图替代‘写什么’时,它无法接入申请人真实的课程强度雷达图、活动时间轴、地域资源约束等物理级成长基底。真正有效的技术介入点,在于非创作环节:用大模型做证据链压力测试、语境显性化增强、审核员注意力模拟。这要求申请者从‘AI使用者’转向‘规则解读者’,将工具锚定在真

weixin_33910460的博客 624

HDU6485 Similar Strings

字符串 尺取

a free man 886

js做算法题-K-Similar Strings

K-Similar Strings 题目来源:LeetCode No.854 题目描述: K-similar字符串的定义:对于任意两个字符串A和B,若对其中一个字符串中的字符交换了K次后(K&gt;=0),使得A与B完全相等,则称A和B为K-similar字符串。 现给定两个字谜A和B为K-similar字符串,返回最小的K。 例1: 输入: A = "ab",B = "ba" ...

weixin_40870788的博客 1030
上一篇: 2021.1.10寒假打卡Day7
下一篇: 2021.1.12寒假打卡Day9
Connorxuan
博客等级 码龄8年 2粉丝 31原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值