IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> C++知识库 -> 第36期《AtCoder Beginner Contest 248 打比赛总结》 -> 正文阅读

[C++知识库]第36期《AtCoder Beginner Contest 248 打比赛总结》

4月16日(周六)又打了一场ABC。

结果:A,B题 AC(300分),C、D题?TLE

目录

网址

视频讲解

A题

题目描述

题目分析

题目代码

知识讲解

B题

题目描述

题目分析

题目代码

题目备注

C题

题目描述

题目分析

题目代码

其它

我的Atcoder账号

版权声明

投票收集


网址

UNIQUE VISION Programming Contest 2022(AtCoder Beginner Contest 248) - AtCoderAtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.https://atcoder.jp/contests/abc248

视频讲解

ABC 248 A~D 讲解

A题

题目描述

A - Lacked Number  / 
Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 100 points

Problem Statement
You are given a string S of length exactly 9 consisting of digits. One but all digits from 0 to 9 appear exactly once in S.

Print the only digit missing in S.

Constraints
S is a string of length 9 consisting of digits.
All characters in S are distinct.
Input
Input is given from Standard Input in the following format:

S
Output
Print the only digit missing in S.

Sample Input 1 
Copy
023456789
Sample Output 1 
Copy
1
The string 023456789 only lacks 1. Thus, 1 should be printed.

Sample Input 2 
Copy
459230781
Sample Output 2 
Copy
6
The string 459230781 only lacks 6. Thus, 6 should be printed.

Note that the digits in the string may not appear in increasing order.

题目分析

题目大意:

输入一个字符串,包含0~9中的9个数字,输出缺失的数。

思路:

先排序,再把字符串从头到尾循环。当i≠s[i],输出i,return 0。如果全部循环过一遍还没return 0,直接输出9(博主刚开始没cout<<9,WA了2次)。

题目代码

初次提交的WA代码:

#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
	cin>>s;
	sort(s.begin(),s.end());
	for(int i=0;i<s.size();i++) if(s[i]!=i+'0') {
		cout<<i;
		return 0;
	} 
    return 0;
}
//ACplease!!!


/*  printf("                                                                \n");
	printf("                                                                \n");
	printf("       * * *               * * *             * * *             * * *            \n");
	printf("     *       *           *       *         *      *          *       *         \n");
	printf("    *        *          *         *       *        *        *         *        \n");
	printf("            *           *         *                *                  *      \n");
	printf("           *            *         *               *                  *     \n");
	printf("          *             *         *              *                  *       \n");
	printf("         *              *         *             *                  *            \n");
	printf("        *               *         *           *                  *            \n");
	printf("      *                  *       *          *                  *           \n");
	printf("    * * * * * * *          * * *          * * * * * * *      * * * * * * *                           \n");
*/    

再次提交的WA代码:

#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
	cin>>s;
	sort(s.begin(),s.end());
	for(int i=0;i<(int)s.size();i++) if(s[i]!=i+'0') {
		cout<<i;
		return 0;
	} 
    return 0;
}
//ACplease!!!


/*  printf("                                                                \n");
	printf("                                                                \n");
	printf("       * * *               * * *             * * *             * * *            \n");
	printf("     *       *           *       *         *      *          *       *         \n");
	printf("    *        *          *         *       *        *        *         *        \n");
	printf("            *           *         *                *                  *      \n");
	printf("           *            *         *               *                  *     \n");
	printf("          *             *         *              *                  *       \n");
	printf("         *              *         *             *                  *            \n");
	printf("        *               *         *           *                  *            \n");
	printf("      *                  *       *          *                  *           \n");
	printf("    * * * * * * *          * * *          * * * * * * *      * * * * * * *                           \n");
*/    

最后的AC代码:

#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
	cin>>s;
	sort(s.begin(),s.end());
	for(int i=0;i<(int)s.size();i++) if(s[i]!=i+'0') {
		cout<<i;
		return 0;
	} 
	cout<<9; 
    return 0;
}
//ACplease!!!


/*  printf("                                                                \n");
	printf("                                                                \n");
	printf("       * * *               * * *             * * *             * * *            \n");
	printf("     *       *           *       *         *      *          *       *         \n");
	printf("    *        *          *         *       *        *        *         *        \n");
	printf("            *           *         *                *                  *      \n");
	printf("           *            *         *               *                  *     \n");
	printf("          *             *         *              *                  *       \n");
	printf("         *              *         *             *                  *            \n");
	printf("        *               *         *           *                  *            \n");
	printf("      *                  *       *          *                  *           \n");
	printf("    * * * * * * *          * * *          * * * * * * *      * * * * * * *                           \n");
*/    

知识讲解

如果有小白不懂排序,可以看下这篇我写的文章:

第8期《排序算法sort》_joe_zxq的编程世界的博客-CSDN博客sort函数用于C++中,对给定区间所有元素进行排序,默认为升序,也可进行降序排序。sort函数进行排序的时间复杂度为n*log2n,比冒泡之类的排序算法效率要高,sort函数包含在头文件为#include<algorithm>的c++标准库中。中文名sort函数外文名sort Function头文件#include <algorithm>用途对给定区间所有元素进行排序所属范畴C++功能升序、降序目录1函数介绍...https://blog.csdn.net/joe_zxq21/article/details/121787278?spm=1001.2014.3001.5502

B题

题目描述

B - Slimes  / 
Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 200 points

Problem Statement
There are A slimes.

Each time Snuke shouts, the slimes multiply by K times.

In order to have B or more slimes, at least how many times does Snuke need to shout?

Constraints
1≤A≤B≤10 
9
 
2≤K≤10 
9
 
All values in input are integers.
Input
Input is given from Standard Input in the following format:

A B K
Output
Print the answer.

Sample Input 1 
Copy
1 4 2
Sample Output 1 
Copy
2
We start with one slime. After Snuke's first shout, we have two slimes; after his second shout, we have four slimes. Thus, he needs to shout at least twice to have four or more slimes.

Sample Input 2 
Copy
7 7 10
Sample Output 2 
Copy
0
We have seven slimes already at the start.

Sample Input 3 
Copy
31 415926 5
Sample Output 3 
Copy
6

题目分析

题目大意:

有一种史莱姆。每次Snuke喊叫时,史莱姆会乘以K倍。

为了有B或更多史莱姆,Snuke至少需要喊多少次?

思路:水题…… 直接无限循环,每次翻倍,当数量≥B时,跳出。

题目代码

AC代码(水……):

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,k;
    cin>>a>>b>>k;
    for(long long i=0;;i++){
    	if(a>=b){
    		cout<<i;
    		return 0;
		}
		a*=k;
	}
	    
    return 0;
}
//ACplease!!!


/*  printf("                                                                \n");
	printf("                                                                \n");
	printf("       * * *               * * *             * * *             * * *            \n");
	printf("     *       *           *       *         *      *          *       *         \n");
	printf("    *        *          *         *       *        *        *         *        \n");
	printf("            *           *         *                *                  *      \n");
	printf("           *            *         *               *                  *     \n");
	printf("          *             *         *              *                  *       \n");
	printf("         *              *         *             *                  *            \n");
	printf("        *               *         *           *                  *            \n");
	printf("      *                  *       *          *                  *           \n");
	printf("    * * * * * * *          * * *          * * * * * * *      * * * * * * *                           \n");
*/    

题目备注

我不相信这题有人WA

欢迎参与文章底部的投票收集。

C题

题目描述

C - Dice Sum  / 
Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 300 points

Problem Statement
How many integer sequences of length N, A=(A 
1
?	
 ,…,A 
N
?	
 ), satisfy all of the conditions below?

1≤A 
i
?	
 ≤M (1≤i≤N)

i=1
∑
N
?	
 A 
i
?	
 ≤K

Since the count can get enormous, find it modulo 998244353.

Constraints
1≤N,M≤50
N≤K≤NM
All values in input are integers.
Input
Input is given from Standard Input in the following format:

N M K
Output
Print the answer.

Sample Input 1 
Copy
2 3 4
Sample Output 1 
Copy
6
The following six sequences satisfy the conditions.

(1,1)
(1,2)
(1,3)
(2,1)
(2,2)
(3,1)
Sample Input 2 
Copy
31 41 592
Sample Output 2 
Copy
798416518
Be sure to print the count modulo 998244353.

题目分析

题目大意:

很短的题目,不解释了。

思路: TLE思路见代码。

题目代码

递归TLE代码:

#include<bits/stdc++.h>
using namespace std;
long long ans=0,n,m,k;
void dfs(long long num,long long sum,long long pos){
	sum+=num;
	if(pos==n&&sum<=k){
		ans++;
		return;
	}
	if(sum>k) return;
	for(long long i=1;i<=m;i++)
	    dfs(i,sum,pos+1);
}
int main(){
	cin>>n>>m>>k;
	dfs(0,0,0);
	cout<<ans%998244353;    
    return 0;
}
//ACplease!!!


/*  printf("                                                                \n");
	printf("                                                                \n");
	printf("       * * *               * * *             * * *             * * *            \n");
	printf("     *       *           *       *         *      *          *       *         \n");
	printf("    *        *          *         *       *        *        *         *        \n");
	printf("            *           *         *                *                  *      \n");
	printf("           *            *         *               *                  *     \n");
	printf("          *             *         *              *                  *       \n");
	printf("         *              *         *             *                  *            \n");
	printf("        *               *         *           *                  *            \n");
	printf("      *                  *       *          *                  *           \n");
	printf("    * * * * * * *          * * *          * * * * * * *      * * * * * * *                           \n");
*/    

其它

D题TLE。

其他没做。

我的Atcoder账号

joe_zxq - AtCoderhttps://atcoder.jp/users/joe_zxq

版权声明

————————————————
版权声明:本文为CSDN博主「joe_zxq21」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明, ?不欢迎?? 欢迎大家的转载和关注。

投票收集

  C++知识库 最新文章
【C++】友元、嵌套类、异常、RTTI、类型转换
通讯录的思路与实现(C语言)
C++PrimerPlus 第七章 函数-C++的编程模块(
Problem C: 算法9-9~9-12:平衡二叉树的基本
MSVC C++ UTF-8编程
C++进阶 多态原理
简单string类c++实现
我的年度总结
【C语言】以深厚地基筑伟岸高楼-基础篇(六
c语言常见错误合集
上一篇文章      下一篇文章      查看所有文章
加:2022-04-26 11:24:29  更:2022-04-26 11:28:26 
 
开发: 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年5日历 -2024/5/20 23:26:13-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码