记录洛谷刷题QAQ,一些不太优雅的代码


一、[COCI2006-2007#1] Okviri

题面翻译

“彼得·潘框架”是一种装饰文字,每一个字母都是由一个菱形框架。一个彼得·潘框架看起来像这样 (x是字母,#是框架):

..#..
.#.#.
#.X.#
.#.#.
..#..

然而,只是一个框架会有些沉闷,所以我们每遇到三个字母会把第三个字母用温迪框架把它框起来。温迪框架看起来像这样:

..*..
.*.*.
*.X.*
.*.*.
..*..

当温迪和彼得·潘的框架重叠时,温迪框架覆盖在上面。 (见样例3和4)

输入格式: 一行包含至多15个英文字母的大写字母。

输出格式: 输出使用彼得·潘和温迪框架写成的5行文字。

题目描述

“Peter Pan frames” are a way of decorating text in which every character is framed by a diamond shaped frame, with frames of neigbhouring characters interleaving. A Peter Pan frame for one letter looks like this (‘X’ is the letter we are framing):

..#..
.#.#.
#.X.#
.#.#.
..#..

However, such a framing would be somewhat dull so we’ll frame every third letter using a “Wendyframe”. A Wendy frame looks like this:

..*..
.*.*.
*.X.*
.*.*.
..*..

When a Wendy frame interleaves with a Peter Pan frame, the Wendy frame (being much nicer) is put on top. For an example of the interleaving check the sample cases.

输入格式

The first and only line of input will contain at most 15 capital letters of the English alphabet.

输出格式

Output the word written using Peter Pan and Wendy frames on 5 lines.

样例 #1

样例输入 #1

A

样例输出 #1

..#..
.#.#.
#.A.#
.#.#.
..#..

样例 #2

样例输入 #2

DOG

样例输出 #2

..#...#...*..
.#.#.#.#.*.*.
#.D.#.O.*.G.*
.#.#.#.#.*.*.
..#...#...*..

样例 #3

样例输入 #3

ABCD

样例输出 #3

..#...#...*...#..
.#.#.#.#.*.*.#.#.
#.A.#.B.*.C.*.D.#
.#.#.#.#.*.*.#.#.
..#...#...*...#..

代码如下:

//一道很烦的题
#include<string.h>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>char ans[10][100];
int main(){char a[16];scanf("%s",&a);for(int i=1;i<=5;++i){int sum1=3,sum2=2,sum3=1;if(i==1||i==5){while(sum1+4<=99){ans[i][sum1]='#',sum1+=4;}}if(i==2||i==4){while(sum2+2<=99){ans[i][sum2]='#',sum2+=2;}}if(i==3){while(sum3+4<=99){ans[i][sum3]='#',sum3+=4;}}}int na=strlen(a);int f1=3;for(int i=0;i<na;++i){ans[3][f1]=a[i];f1+=4;}f1-=2;int qaq=11;while(qaq<f1){for(int i=1;i<=5;++i){if(i==1||i==5){ans[i][qaq]='*';}if(i==2||i==4){ans[i][qaq+1]='*';ans[i][qaq-1]='*';}if(i==3){ans[i][qaq-2]='*';ans[i][qaq+2]='*';}}qaq+=12;}for(int i=1;i<=5;++i){for(int j=1;j<=f1;++j){if((ans[i][j]!='*'&&ans[i][j]!='#')&&(ans[i][j]<'A'||ans[i][j]>'Z')){printf(".");}else printf("%c",ans[i][j]);}printf("\n");}return 0;
}

二、[COCI2006-2007#2] R2

题面翻译

设S=(R1+R2)/2,给定R1与S (−1000<=R1,S<=1000)(-1000<=R1,S<=1000)(−1000<=R1,S<=1000),求R2。

感谢@Xeonacid 提供的翻译

题目描述

The number S is called the mean of two numbers R1 and R2 if S is equal to (R1+R2)/2. Mirko’s birthday present for Slavko was two integers R1 and R2. Slavko promptly calculated their mean which also happened to be an integer but then lost R2! Help Slavko restore R2.

输入格式

The first and only line of input contains two integers R1 and S, both between -1000 and 1000.

输出格式

Output R2 on a single line.

样例 #1

样例输入 #1

11 15

样例输出 #1

19

样例 #2

样例输入 #2

4 3

样例输出 #2

2

代码如下:

//一道简单的题
#include<string.h>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>int main(){long long one , ans;scanf("%lld%lld",&one,&ans);long long two = 2.0*ans - one;printf("%lld\n",two);return 0;
}

三、[COCI2006-2007#2] ABC

题面翻译

【题目描述】

三个整数分别为 A,B,CA,B,CA,B,C。这三个数字不会按照这样的顺序给你,但它们始终满足条件:A<B<CA < B < CA<B<C。为了看起来更加简洁明了,我们希望你可以按照给定的顺序重新排列它们。

【输入格式】

第一行包含三个正整数 A,B,CA,B,CA,B,C,不一定是按这个顺序。这三个数字都小于或等于 100100100。第二行包含三个大写字母 AAA、BBB 和 CCC(它们之间没有空格)表示所需的顺序。

【输出格式】

在一行中输出 AAA,BBB 和 CCC,用一个 (空格)隔开。

感谢 @smartzzh 提供的翻译

题目描述

You will be given three integers A, B and C. The numbers will not be given in that exact order, but we do know that A is less than B and B less than C.
In order to make for a more pleasant viewing, we want to rearrange them in the given order.

输入格式

The first line contains three positive integers A, B and C, not necessarily in that order. All three numbers will be less than or equal to 100.
The second line contains three uppercase letters ‘A’, ‘B’ and ‘C’ (with no spaces between them) representing the desired order.

输出格式

Output the A, B and C in the desired order on a single line, separated by single spaces.

样例 #1

样例输入 #1

1 5 3
ABC

样例输出 #1

1 3 5

样例 #2

样例输入 #2

6 4 2
CAB

样例输出 #2

6 2 4

代码如下:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>int small(int a, int b,int c){int point = a;if(b < point)point = b;if(c < point)point = c;return point;
}int big(int a, int b,int c){int point = a;if(b > point)point = b;if(c > point)point = c;return point;
}
int main(int argc, char *argv[]) {int A, B, C ;int a, b, c;while(scanf("%d%d%d",&a,&b,&c)!=EOF){A = small(a,b,c);C = big(a,b,c);B = a+b+c-A-C; //printf("%d %d %d\n",A,B,C);char num[4];scanf("%s",&num);int len = strlen(num);for(int i = 0;i < len;i++){if(num[i] == 'A')printf("%d ",A);if(num[i] == 'B')printf("%d ",B);if(num[i] == 'C')printf("%d ",C);}printf("\n");}return 0;
}

四、[COCI2017-2018#3] Aron

题面翻译

Aron给他的朋友们买礼物后在礼物店排队,它的前面有n个人,但是它发现有些人实在等待他的朋友而并非在排队买单,并且我们可以认为站在一个人后面的朋友都穿着匹配颜色的衬衫,而两个相邻的群体、相邻的个人或相邻的个人和一个集体将永远不会穿着相同颜色的衬衫。

编写一个程序,给定排队的人所穿的衣服的颜色,输出Aron在第多少位?

题目描述

The holiday season is near! Aron wants to get gifts for his friends in Zagreb, so in order to get them on time, he visited a famous toy store in London. After picking out the gifts, he went to the register and discovered that there were already N people in line. Luckily, he noticed that there were groups of people standing in line, in addition to individual customers. A group of people consists of a customer and their friends waiting for them to complete the purchase.
The moment when the customer is done, they and their friends leave the line.

The people considered a group are standing one behind the other and are wearing shirts of matching colour. Two adjacent groups, adjacent individuals or adjacent individual and a group, will never be wearing shirts of the same colour.

Write a program that will, given the data on the people standing in line, output which person in line Aron is.

输入格式

The first line of input contains the positive integer N (1 ≤ N ≤ 25) from the task.
Each of the following N lines contains a single character, an uppercase letter of the English alphabet that represents the shirt colour of the ithi^{th}ith person in line.

输出格式

You must output the required number from the task.

样例 #1

样例输入 #1

3
C
Z
P

样例输出 #1

4

样例 #2

样例输入 #2

6
C
C
P
C
Z
Z

样例输出 #2

5

样例 #3

样例输入 #3

6
B
B
B
B
B
B

样例输出 #3

2

提示

Clarification​ ​of​ ​the​ ​second​ ​test​ ​case:

First in line is the group consisting of two people in red shirts. Second in line is an individual in the blue shirt, third in line is an individual in the red shirt, and fourth in line is a group in green shirts. This makes Aron fifth in line.

代码如下:


#include<string.h>
#include<stdio.h>
#include<math.h>
#include <stdlib.h>int main(){int n;//前面有n个人scanf("%d",&n);char num[n];for(int i = 0; i < n;i++){scanf("%s",&num[i]);   } int sum = n;for(int i = 0;i < n-1;i++){if(num[i] == num[i+1]){sum--;}}printf("%d\n",sum+1);return 0;
}

五、[AHOI2018初中组]报名签到

题目描述

nnn 位同学(编号从 111 到 nnn)同时来到体育馆报名签到,领取准考证和参赛资料。为了有序报名,这 nnn 位同学需要按编号次序(编号为 111 的同学站在最前面)从前往后排成一条直线。然而每一位同学都不喜欢拥挤,对于第 iii 位同学,如果有另外一位同学距离他/她的距离小于 aia_iai​,那么就会发生冲突。小可可想知道如果要不发生任何冲突的情况下,这 nnn 位同学排队的队列最短长度是多少。

输入格式

第一行一个整数 nnn ,表示报名签到的同学人数。

第二行有 nnn 个整数,第 iii 个整数 aia_iai​ 表示第 iii 个同学必须与其他同学保持的距离。

输出格式

输出一行,包括一个整数,表示这 nnn 位同学排队队列的最小长度。

注意: nnn 位同学要按 111 到 nnn 的次序从前往后排队。

样例 #1

样例输入 #1

3
3 1 2

样例输出 #1

5

提示

对于 20%20\%20% 的数据满足:1≤n≤201\le n\le 201≤n≤20。

对于 70%70\%70% 的数据满足:1≤n≤1041\le n\le 10^41≤n≤104。

对于 100%100\%100% 的数据满足:1≤n≤1051\le n\le 10^51≤n≤105,1≤ai≤1051\le a_i\le 10^51≤ai​≤105。

代码如下:

#include <stdio.h>
#include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */
//找到最小值
int small(int a, int b){int point = a;if(a <= b){point = b;}return point;
}
int main(int argc, char *argv[]) {long long  n;scanf("%d",&n);long long i;long long sum = 0;int NUM[n];for(i = 0;i < n;i++){scanf("%d",&NUM[i]);}long long point; for(i = 0;i < n-1;i++){point = small(NUM[i],NUM[i+1]);sum = point +sum;}printf("%lld\n",sum);return 0;
}

洛谷刷题C语言:Okviri、R2、ABC、Aron、报名签到相关推荐

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  9. 洛谷刷题C语言:数字反转、再分肥皂水、三角形面积、Apples Prologue/苹果和虫子、数的性质

    记录洛谷刷题QAQ,一些不大优雅的代码 一.[深基2.例7]数字反转 题目描述 输入一个不小于 100100100 且小于 100010001000,同时包括小数点后一位的一个浮点数,例如 123.4 ...

最新文章

  1. apache ant 安装_SAP Hybris使用recipe进行安装时,是如何执行ant命令的?
  2. 二十六、内存管理的概念
  3. [动态代理三部曲:上] - 动态代理是如何坑掉了我4500块钱
  4. python 导入csv文件到oracle_python将文件夹下的所有csv文件存入mysql和oracle数据库
  5. php 系统模版_原生 PHP 模板系统:Plates
  6. Windows 下搭建 Ruby 开发环境
  7. php写好的接口怎么返回数据库,用PHP开发app接口,连接了数据库,调试的时候正常输出,但是转为json格式返回的数据为null...
  8. 从 GitHub 上手动安装python包教程
  9. GridView的dataformatstring设置
  10. 计算广告学习资料汇总
  11. 第五次作业 刘惠惠 自动生成的方法存根
  12. 关于微信在线客服系统的实现(已经证实可用)
  13. 高盛区块链79页完整报告:从理论到实践!
  14. centos6查看运行服务器,centos如何查看端口是否开放_网站服务器运行维护,centos,端口...
  15. AutoLeaders——翁恺老师的结构的笔记
  16. 骑行318、 2016.7.17
  17. 杭州电子科技大学程序设计竞赛(2016’12)- 网络同步赛 1004
  18. 【案例】简单图片和段落上下排版制作
  19. 社区宽带繁忙是什么意思_智慧社区盈利模式分析
  20. java反编译工具gd gson,浅谈Android中static修饰符,及Gson转String实例

热门文章

  1. <Zhuuu_ZZ>HIVE(十一)函数
  2. 昨天去看了电影-《达芬奇密码》
  3. 三菱MR-JE-C伺服应用详细介绍
  4. 人民日报发推欢迎Google回归,但前提是遵守中国法律
  5. TPM分析笔记(十二)TPM PCR操作
  6. 微信小程序上传头像先裁剪图片后上传
  7. 【Vue3.0】Vue3.0简介-指令-过滤器-案例D2.0
  8. 输入存款金额m、存期(年)y和年利率r,计算并输出到期的利息p
  9. PBOC/EMV之小额支付, 电子钱包和借贷记
  10. 原生JS八(Math对象,随机色)