| |
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
-> C++知识库 -> AtCoder Beginner Contest 042(Virtual Participation) -> 正文阅读 |
|
[C++知识库]AtCoder Beginner Contest 042(Virtual Participation) |
本菜鸟的情况:? A - Iroha and Haiku (ABC Edition)?Time Limit: 2 sec / Memory Limit: 256 MB Score : 100?points Problem StatementIroha loves?Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with?5,?7?and?5?syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have?A,?B?and?C?syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. Constraints
InputThe input is given from Standard Input in the following format: A B C OutputIf it is possible to construct a Haiku by using each of the phrases once, print? Sample Input 15 5 7 Sample Output 1YES Using three phrases of length?5,?5?and?7, it is possible to construct a Haiku. Sample Input 27 7 5 Sample Output 2NO ?解题思路: ? ? ? ? 这个题还是非常简单的,实际上就是要去判断输入的三个数是不是5,5,7(顺序无所谓),是的话则输出YES,否则的话输出NO。简单来说直接拿个数组,排序之后判断就可以了。 AC代码:
B - Iroha Loves Strings (ABC Edition)Time Limit: 2 sec / Memory Limit: 256 MB Score : 200?points Problem StatementIroha has a sequence of?N?strings?S1?,S2?,...,SN?. The length of each string is?L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s1?s2?s3?...sn??is?lexicographically smaller?than another string t=t1?t2?t3?...tm??if and only if one of the following holds:
Constraints
InputThe input is given from Standard Input in the following format: N L S1? S2? : SN? OutputPrint the lexicographically smallest string that Iroha can produce. Sample Input 13 3 dxx axx cxx Sample Output 1axxcxxdxx The following order should be used:? ? 解题思路: ? ? ? ? 别问我为啥错了这么多次,把拼接字符串的个数写成了L,害的我找了半天才找出来。这个题其实只需要用一个string数组,进行排序后一个一个拼接在后面就可以了。 AC代码:
C - Iroha's ObsessionTime Limit: 2 sec / Memory Limit: 256 MB Score :?300?points Problem StatementIroha is very particular about numbers. There are?K?digits that she dislikes: D1?,D2?,...,DK?. She is shopping, and now paying at the cashier. Her total is?N?yen (the currency of Japan), thus she has to hand at least?N?yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier. Constraints
InputThe input is given from Standard Input in the following format: N K D1? D2? … DK? OutputPrint the amount of money that Iroha will hand to the cashier. Sample Input 11000 8 1 3 4 5 6 7 8 9 Sample Output?2000 She dislikes all digits except?0?and?2. The smallest integer equal to or greater than N=1000?whose decimal notation contains only?0?and?2, is?2000. Sample Input 29999 1 0 Sample Output 29999 解题思路: ? ? ? ? 这个题我一开始想得太复杂了,后来才反应过来直接暴力解就可以。先把D数组中出现的数标记一下,之后一位一位的进行比较,看看每一位的数字是否都不在D中出现。直到出现正确答案为止。 AC代码:
D - Iroha and a GridTime Limit: 2 sec / Memory Limit: 256 MB Score :?400?points Problem StatementWe have a large square grid with?H?rows and?W?columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell. However, she cannot enter the cells in the intersection of the bottom?A?rows and the leftmost?B?columns. (That is, there are A×B?forbidden cells.) There is no restriction on entering the other cells. Find the number of ways she can travel to the bottom-right cell. Since this number can be extremely large, print the number modulo?. Constraints
InputThe input is given from Standard Input in the following format: H W A B OutputPrint the number of ways she can travel to the bottom-right cell, modulo?. Sample Input 12 3 1 1 Sample Output 12 We have a?2×3?grid, but entering the bottom-left cell is forbidden. The number of ways to travel is two: "Right, Right, Down" and "Right, Down, Right". Sample Input 210 7 3 4 Sample Output 23570 There are?12?forbidden cells. Sample Input 3100000 100000 99999 99999 Sample Output 31 Sample Input 4100000 100000 44444 55555 Sample Output 4738162020 解题思路: ? ? ? ? 这个题在一开始没有做出来。开始的思想很简单,想着用dp直接做,但是都失败了,因为这个二维数组开得太大,结束之后看题解才发现了一个类似于杨辉三角的模型,正解应该是拿类似于排列组合的思想。这个就涉及到组合数学中的常用算法,此处应用的是组合问题(有关组合数学的相关知识点),即的计算,套路是很固定的,直接套模板即可。 ? ? ? ??方案数的求解 AC代码:
|
|
C++知识库 最新文章 |
【C++】友元、嵌套类、异常、RTTI、类型转换 |
通讯录的思路与实现(C语言) |
C++PrimerPlus 第七章 函数-C++的编程模块( |
Problem C: 算法9-9~9-12:平衡二叉树的基本 |
MSVC C++ UTF-8编程 |
C++进阶 多态原理 |
简单string类c++实现 |
我的年度总结 |
【C语言】以深厚地基筑伟岸高楼-基础篇(六 |
c语言常见错误合集 |
|
上一篇文章 下一篇文章 查看所有文章 |
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 | -2024/11/24 6:19:43- |
|
网站联系: qq:121756557 email:121756557@qq.com IT数码 |