记录洛谷刷题QAQ


一、[COCI2017-2018#5] Olivander

题面翻译

题意简述

有 n n n 个棍子和 n n n 个盒子,要求每个盒子里放的棍子的总长度不能超过盒子的高度。求是否有方案使得各个棍子都能放到任意一个盒子里。是输出 DA,否则输出 NE。(一个盒子里只能放一根棍子)

输入

输入共三行。

第一行,一个整数 n n n。

第二行, n n n 个整数 X 1 , X 2 , X 3 , … , X n X_1,X_2,X_3,\dots,X_n X1​,X2​,X3​,…,Xn​。其中第 i i i个数 X i X_i Xi​表示第 i i i根棍子的长度。

第三行, n n n个整数 Y 1 , Y 2 , Y 3 , … , Y n Y_1,Y_2,Y_3,\dots,Y_n Y1​,Y2​,Y3​,…,Yn​。其中第 i i i 个数 Y i Y_i Yi​ 表示第 i i i 个盒子的高度。

输出

输出仅一行。即如果有能够将各个棍子都能放进任一盒子的方案输出 DA,否则输出 NE(输出不包括引号)。

样例解释

样例 1 1 1:哈利波特能够将所有棍子放进盒子里面。例如 X 1 ⇒ Y 3 , X 2 ⇒ Y 2 , X 3 ⇒ Y 1 X_1\Rightarrow Y_3,X_2\Rightarrow Y_2,X_3\Rightarrow Y_1 X1​⇒Y3​,X2​⇒Y2​,X3​⇒Y1​。

样例 2 2 2:哈利波特不能够将所有棍子放进盒子里。
因为 Y 2 = 2 Y_2=2 Y2​=2,不能塞下任何一根棍子。

数据范围

对于 60 % 60\% 60% 的数据,保证 n ⩽ 9 n\leqslant9 n⩽9。

对于 100 % 100\% 100% 的数据,保证 n ⩽ 100 n\leqslant100 n⩽100,并且 ∀ i \forall i ∀i,都满足 X i , Y i ⩽ 1 0 9 X_i,Y_i\leqslant10^9 Xi​,Yi​⩽109。

题目描述

Harry Potter has damaged his magic wand in a fight with Lord Voldemort. He has decided to
get a new wand in Olivander’s wand shop. On the floor of the shop, he saw ​N wands and ​N
wand boxes. The lengths of the wands are, respectively, X 1 X_1 X1​
, X 2 X_2 X2​
…​ X n X_n Xn​
, and the box sizes are
Y 1 Y_1 Y1​
,​ Y 2 Y_2 Y2​
… Y n Y_n Yn​
. A wand of length ​X can be placed in a box of size ​Y if ​X ≤ ​Y
. Harry wants to know
if he can place all the wands in boxes so that each box contains exactly one wand.
Help him solve this difficult problem.

输入格式

The first line of input contains the positive integer ​N
(1 ≤ ​N
≤ 100), the number from the task.
The second line contains ​N
positive integers ​ X i X_i Xi​
(1 ≤ ​ X i X_i Xi​
≤ 1 0 9 10^9 109​ ), the numbers from the task.
The third line contains ​N
positive integers ​ X i X_i Xi​
(1 ≤ X i X_i Xi​
≤ 1 0 9 10^9 109​​ ), the numbers from the task.

输出格式

If Harry can place all the wands in boxes, output “DA” (Croatian for yes), otherwise output
“NE” (Croatian for no).

样例 #1

样例输入 #1

3
7 9 5
6 13 10

样例输出 #1

DA

样例 #2

样例输入 #2

4
5 3 3 5
10 2 10 10

样例输出 #2

NE

样例 #3

样例输入 #3

4
5 2 3 2
3 8 3 3

样例输出 #3

DA

提示

In test cases worth 60% of total points, it will hold ​N
≤ 9.

Clarification of the first test case:

Harry can place the wands in boxes. For example, he can place the wand of length 5 in a box of size
6, wand of length 7 in a box of size 13, and wand of length 9 in a box of size 10.

Clarification of the second test case:

Harry can’t place the wands in boxes because the box of size 2 can’t fit any of the wands.

代码如下:


#include<string.h>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>int main(){int n;//盒子和棍子的总数scanf("%d",&n);int len[n];for(int i = 0;i < n;i++){scanf("%d",&len[i]);}int high[n];for(int i = 0;i < n;i++){scanf("%d",&high[i]);}for(int i = 0;i < n;i++){for(int j =i;j < n;j++){if(len[i] > len[j]){len[i] = len[i] + len[j];len[j] = len[i] - len[j];len[i]= len[i] - len[j];}if(high[i] >high[j]){high[i] = high[i] + high[j];high[j] = high[i] - high[j];high[i]= high[i] - high[j];}}}int num = 0;for(int i = 0 ;i < n;i++){if(len[i] <= high[i]){num++;}else if(len[i] > high[i]){printf("NE\n");break;}}if(num == n)  printf("DA\n");return 0;
}

二、取石子

题目描述

Alice 和 Bob 在玩游戏。

他们有 n n n 堆石子,第 i i i 堆石子有 a i a_i ai​ 个,保证初始时 a i ≤ a i + 1 ( 1 ≤ i < n ) a_i \leq a_{i + 1}(1 \leq i < n) ai​≤ai+1​(1≤i<n)。现在他们轮流对这些石子进行操作,每次操作人可以选择满足 a i > a i − 1 a_i > a_{i - 1} ai​>ai−1​( a 0 a_0 a0​ 视为 0 0 0)的一堆石子,并从中取走一个。谁最后不能取了谁输。Alice 先手,他们都使用最优策略,请判断最后谁会取得胜利。

输入格式

第一行一个整数 n ( 1 ≤ n ≤ 100 ) n(1 \leq n \leq 100) n(1≤n≤100),表示石子堆数。

接下来一行 n n n 个数,第 i i i 个数为 a i ( 1 ≤ a i ≤ 1 0 9 ) a_i(1 \leq a_i \leq 10^9) ai​(1≤ai​≤109),意义如上所述。

输出格式

“Alice” 或 “Bob”,表示谁会赢。

样例 #1

样例输入 #1

1
1

样例输出 #1

Alice

样例 #2

样例输入 #2

1
2

样例输出 #2

Bob

代码如下:

#include <stdio.h>
#include <stdlib.h>
#define M  100int main(int argc, char *argv[]) {int n;long long int NUM[M],sum = 0;int i;scanf("%d",&n);for(i = 0;i < n;i++){scanf("%lld",&NUM[i]);} for(i = 0;i < n;i++){sum = sum + NUM[i];}if(sum%2==0)printf("Bob");else printf("Alice");return 0;
}

三、[COCI2017-2018#6] Davor

题面翻译

在征服南极之后,Davor 开始了一项新的挑战。下一步是在西伯利亚、格林兰、挪威的北极圈远征。他将在 2018 2018 2018 年 12 12 12 月 31 31 31 日开始出发,在这之前需要一共筹集 n n n 元钱。他打算在每个星期一筹集 x x x 元,星期二筹集 x + k x+k x+k 元,……,星期日筹集 x + 6 k x+6k x+6k 元,并连续筹集 52 52 52 个星期。其中 x , k x,k x,k 为正整数,并且满足 1 ≤ x ≤ 100 1 \le x \le 100 1≤x≤100。

现在请你帮忙计算 x , k x,k x,k 为多少时,能刚好筹集 n n n 元。

如果有多个答案,输出 x x x 尽可能大, k k k 尽可能小的。注意 k k k 必须大于 0 0 0。

题目描述

After successfully conquering the South Pole, Davor is preparing for new challenges. Next up is the Arctic expedition to Siberia, Greenland and Norway. He begins his travels on 31 December 2018, and needs to collect ​N kunas (Croatian currency) by then. In order to do this, he has decided to put away ​X (​X ≤ 100) kunas every Monday to his travel fund, ​X + K kunas every Tuesday, ​X + 2* ​K every Wednesday, and so on until Sunday, when he will put away ​X + 6* ​K kunas. This way, he will collect money for 52 weeks, starting with 1 January 2018 (Monday) until 30 December 2018 (Sunday).

If we know the amount of money ​N​, output the values ​X and ​K so that it is possible to collect the ​exact money amount in the given timespan. The solution will always exist, and if there are multiple, output the one with the greatest ​X ​ and smallest ​K ​.

输入格式

The first line of input contains the integer ​N​ (1456 ≤ ​N​ ≤ 145600), the number from the task.

输出格式

The first line of output must contain the value of ​X (​0 < ​X ​≤ 100 ​)​, and the second the value of
K (K ​> 0 ​)​.

样例 #1

样例输入 #1

1456

样例输出 #1

1
1

样例 #2

样例输入 #2

6188

样例输出 #2

14
1

样例 #3

样例输入 #3

40404

样例输出 #3

99
4

代码如下:

#include<string.h>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>int main(){int n, k = 1;long long num;scanf("%lld",&num);int price = num / 364;do{n = price - 3*k;k++;}while(n > 100);printf("%d\n",n);printf("%d\n",k - 1);return 0;
}

四、[NOIP2018 普及组] 标题统计

题目描述

凯凯刚写了一篇美妙的作文,请问这篇作文的标题中有多少个字符? 注意:标题中可能包含大、小写英文字母、数字字符、空格和换行符。统计标题字 符数时,空格和换行符不计算在内。

输入格式

输入文件只有一行,一个字符串 s s s。

输出格式

输出文件只有一行,包含一个整数,即作文标题的字符数(不含空格和换行符)。

样例 #1

样例输入 #1

234

样例输出 #1

3

样例 #2

样例输入 #2

Ca 45

样例输出 #2

4

提示

【输入输出样例 1 说明】
标题中共有 3 个字符,这 3 个字符都是数字字符。

【输入输出样例 2 说明】 标题中共有$ 5$ 个字符,包括 1 1 1 个大写英文字母, 1 1 1 个小写英文字母和 2 2 2 个数字字符, 还有 1 1 1 个空格。由于空格不计入结果中,故标题的有效字符数为 4 4 4 个。

【数据规模与约定】
规定 ∣ s ∣ |s| ∣s∣ 表示字符串 s s s 的长度(即字符串中的字符和空格数)。
对于 40 % 40\% 40% 的数据, 1 ≤ ∣ s ∣ ≤ 5 1 ≤ |s| ≤ 5 1≤∣s∣≤5,保证输入为数字字符及行末换行符。
对于 80 % 80\% 80% 的数据, 1 ≤ ∣ s ∣ ≤ 5 1 ≤ |s| ≤ 5 1≤∣s∣≤5,输入只可能包含大、小写英文字母、数字字符及行末换行符。
对于 100 % 100\% 100% 的数据, 1 ≤ ∣ s ∣ ≤ 5 1 ≤ |s| ≤ 5 1≤∣s∣≤5,输入可能包含大、小写英文字母、数字字符、空格和行末换行符。

代码如下:

#include<string.h>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>int main(){char num[6];gets(num);//读入一行 int len = strlen(num);int sum = 0;for(int i = 0;i < len;i++){if(num[i] >= 'A'&&num[i] <='Z'){sum++;}if(num[i] >= '0'&&num[i] <='9'){sum++;}if(num[i] >= 'a'&&num[i] <='z'){sum++;}}printf("%d\n",sum);return 0;
}

五、成绩

题目背景

小奔的score

题解:https://blog.csdn.net/kkkksc03/article/details/84928268

说一句:本题已放开空间范围(不过真的貌似不用开数组就可以A呀

题目描述

小奔的期末考试结束了。

他的成绩不久之后就会发下来。

给出一个考试成绩表格,例如:

科目/分值种类 语文 数学 英语
满分 100 100 100 120 120 120 150 150 150
实际得分 99 99 99 73 73 73 100 100 100

当然。学校的老师认为如果录入如此多的成绩不好算分,于是他想要你的综合成绩评定

综合成绩评定指:(每一科的满分之和*3-每一科的实际得分之和*2)÷每科所扣除分数的和。

小奔想请你给出他的综合成绩,你能做到吗?

输入格式

第一行给出一个整数 n n n,表示科目的总数。
第二行 n n n个整数 a i a_i ai​,表示第 i i i门课程的满分。
第三行 n n n个整数 b i b_i bi​,表示第 i i i门课程小奔的实际得分。

输出格式

一行一个数,表示他的综合成绩。结果保留 6 6 6位小数

样例 #1

样例输入 #1

3
10 10 10
5 5 5

样例输出 #1

4.000000

提示

对于 20 20 20%的数据,数据为样例

对于 100 100 100%的数据, n < = 1 e 7 n<=1e7 n<=1e7

代码如下:

#include<stdio.h>
int main()
{double n, sum1 = 0, sum2 = 0, score;scanf("%lf", &n);for(int i = 0; i < n; i++){scanf("%lf", &score);sum1 += score;}for(int i = 0; i < n; i++){scanf("%lf", &score);sum2 += score;}printf("%.6lf", (sum1 * 3 - sum2 * 2) / (sum1 - sum2));return 0;
}

洛谷刷题C语言:Olivander、取石子、Davor、标题统计、成绩相关推荐

  1. 洛谷刷题C语言:陶瓷项链、Cow Gymnastics B、Where Am I? B、Hello, 2020!、SIR 模型

    记录洛谷刷题C语言 一.[NOI2000] 瓷片项链 题目描述 原始部落用一种稀有的泥土烧制直径相同的圆瓷片并串成项链,串的时候沿瓷片的直径方向顺次连接,瓷片之间没有空隙也不重叠,一条项链至少由一个瓷 ...

  2. 洛谷刷题C语言:Physics Problem、PARKING、Trol、信息学竞赛、POT

    记录洛谷刷题C语言 「dWoi R1」Physics Problem 题目背景 面对白板上的物理题,王马陷入了沉思 -- 题目描述 有 nnn 个状态,编号为 111 到 nnn.这 nnn 个状态之 ...

  3. 洛谷刷题C语言:Fergusonball Ratings、Don‘t Mozheng. /oh、gcd.、幻想乡扑克游戏、PMTD

    记录洛谷刷题C语言qaq [CCC2022 J2] Fergusonball Ratings 题目描述 现在有一个球队需要你评价. 球队中的第 i i i 个人进了 a i a_i ai​ 个球,犯规 ...

  4. 洛谷刷题C语言:远古档案馆(Ancient Archive)、VOLIM、SAHOVNICA、Tuna、KRIŽALJKA

    记录洛谷刷题C语言qaq,都是些不优雅的代码 远古档案馆(Ancient Archive) 题目背景 为了揭开月光能量背后的秘密,你来到了地下的远古档案馆. 远古一族的秘密与遗忘的知识悉数贮藏于这片被 ...

  5. 洛谷刷题C语言:潇湘の雨、分糖果、Addition、Ljeto、TRI

    记录洛谷刷题C语言QAQ 「PMOI-0」潇湘の雨 题目背景 (原 LZOI-1,改名已经 PMOI 成员同意) lhm-01 题目描述 言琢დ 在一个 2n×2n2n \times 2n2n×2n ...

  6. 洛谷刷题C语言:Bold、饱食、公平の意、DOM、

    记录洛谷刷题C语言qaq [COCI2020-2021#6] Bold 题目描述 Paula 给 Daniel 写了一封信,她需要加粗文本的字体,以便视力恶化的 Daniel 阅读. 信可以用 . 和 ...

  7. 洛谷刷题C语言:切蛋糕、概率、Bridž、NOTE、DOMINO

    记录洛谷刷题C语言qaq [NOI Online 2021 入门组] 切蛋糕 题目描述 Alice.Bob 和 Cindy 三个好朋友得到了一个圆形蛋糕,他们打算分享这个蛋糕. 三个人的需求量分别为 ...

  8. 洛谷刷题C语言:闰年判断、Apples、洛谷团队系统、肥胖问题、三位数排序

    记录洛谷刷题QAQ 一.[深基3.例3]闰年判断 题目描述 输入一个年份,判断这一年是否是闰年,如果是输出 111,否则输出 000. 输入格式 输入一个正整数 nnn,表示年份. 输出格式 输出一行 ...

  9. 洛谷刷题C语言:LJESTVICA、FUNGHI、LJESNJAK、AUTORI、PLANINA

    记录洛谷刷题QAQ [COCI2012-2013#5] LJESTVICA 题目背景 Veronica 在音乐学院上学,她拿到了一张只有音符的乐谱,并且需要识别其所使用的音阶. 题目描述 在这个问题中 ...

最新文章

  1. Python---20行代码爬取斗鱼平台房间数据(上)
  2. HTTP/1问题和HTTP/2解决思路
  3. 浅析TCP之SACK(选择性确认)
  4. shell编程之数学运算
  5. java工具配置_Java™ 教程(配置实用工具)
  6. 三维重建:SLAM的尺度和方法论问题
  7. 【HDU - 6447】YJJ's Salesman(降维dp,树状数组优化dp)
  8. pyecharts 间距_高月双色球20108期:红球首尾间距参考29区段
  9. 游戏服务器维护启动需要多久,游戏服务器开机需要多长时间
  10. [Deprecated( please use panBy and panTo APIs )]
  11. knowledge_based topic model - 基于知识的主题模型概述
  12. sql批量修改数据_Excel技巧 | 如何批量修改行列数据
  13. 操作系统安装磁盘清理方法
  14. strongSwan之ipsec.secrets配置手册
  15. html5页面风格,H5页面的设计风格有哪些?
  16. LeetCode 494. Target Sume
  17. 8.2 知识蒸馏方法概述
  18. 《世界因你不同》——大学生活:贫穷而快乐的日子
  19. ICC2 user guide(二)Placement and Optimization
  20. flutter常用库整理

热门文章

  1. 不合格的电线电缆有哪些危害
  2. 常见的SQL笔试题和面试题(上):经典50题
  3. 2019天下3最新服务器,天下3:2019标准号全民竞技赛【太虚】门派定位解析及入门讲解...
  4. 写段子,写文案,看看《脱口秀大会4》
  5. 第一周CoreIDRAW课总结
  6. 南京晓庄学院计算机组成原理实验报告,2013-2014年第一学期南京晓庄学院计算机组成原理期末考试回忆版...
  7. runtime-complier 和 runtime-only 的区别
  8. nginx域名隐性(地址栏域名不变)跳转【nginx 跳转 隐藏 被跳转的域名】
  9. dumpbin的使用方法_DEPENDS工具和DUMPBIN工具使用
  10. PHP/其他语言 - 程序员内功心法 常用工具 - 学习/实践