AtCoder Beginner Contest 336 C - Even Digits题解

这篇具有很好参考价值的文章主要介绍了AtCoder Beginner Contest 336 C - Even Digits题解。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

C - Even Digits Editorial


Time Limit: 2 sec / Memory Limit: 1024 MB

Score: 300300 points

Problem Statement

A non-negative integer �n is called a good integer when it satisfies the following condition:

  • All digits in the decimal notation of �n are even numbers (00, 22, 44, 66, and 88).

For example, 00, 6868, and 20242024 are good integers.

You are given an integer �N. Find the �N-th smallest good integer.

Constraints

  • 1≤N≤10^12
  • N is an integer.

Input

The input is given from Standard Input in the following format:

N

Output

Print the N-th smallest good integer.


Sample Input 1Copy

Copy

8

Sample Output 1Copy

Copy

24

The good integers in ascending order are 0,2,4,6,8,20,22,24,26,28,…0,2,4,6,8,20,22,24,26,28,….
The eighth smallest is 2424, which should be printed.


Sample Input 2Copy

Copy

133

Sample Output 2Copy

Copy

2024

Sample Input 3Copy

Copy

31415926535

Sample Output 3Copy

Copy

200662886824422

题解:

要精用vector,防止超时。

#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> a;//类似高精度
int n;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    cin >> n;
    n-=1;//因为第一位是0嘛
    while(n > 0){//2*5=10进位了
        a.push_back(n%5);
        n /= 5;
    }
    if(a.empty()) a.push_back(0);
    for(int i = a.size()-1; i > -1; i--)//迭代器,也不算吧,vector也是数组
        cout << 2*a[i];
    }文章来源地址https://www.toymoban.com/news/detail-806591.html

到了这里,关于AtCoder Beginner Contest 336 C - Even Digits题解的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • ABC 336 C - Even Digits

    先看一下ABC 336 C - Even Digits的题目(大致就是输入一个数n,输出第n个只由0,2,4,6,8组成的数) Time Limit: 2 sec / Memory Limit: 1024 MB Score: 300 points A non-negative integer n is called a good integer when it satisfies the following condition: All digits in the decimal notation of n are even numbers (0, 2, 4, 6, and 8).

    2024年01月20日
    浏览(30)
  • AtCoder Beginner Contest 317 题解 ABCDE | JorbanS

    题意 求权值和最大的一条路径 Tag dfs 题意 n × m n×m n × m 的迷宫, . 代表可以走, # 代表障碍物, ^v 代表射线,射线方向不能走,知道射线遇到非 . 的格子,求最短路 Tag bfs

    2024年02月10日
    浏览(23)
  • AtCoder Beginner Contest 302 H. Ball Collector 题解

    为了更好的阅读体验,请单击这里 AtCoder Beginner Contest 302 H. Ball Collector 题意跳过。 可以视作将 (a_i, b_i) 之间连了一条边,然后 (a_i, b_i) 之间只能选一个等价于对于一条边只能选择其一个端点。那么对于只包含树的联通块而言,如果都选择儿子节点,那么会有一个根节点无

    2024年02月06日
    浏览(24)
  • Atcoder Beginner Contest 324 F Beautiful Path 题解-分数规划

    为了更好的阅读体验,请点击这里 分数规划小技巧: 尽可能将式子写成存在某种取值,使得不等式成立的形式。 不然可能需要绕几个弯才能想出来。 题目链接 题目大意:给出一个 DAG,每条边有一个 (b_i, c_i) ,保证从编号小的边向编号大的边连边,且 (1) 到 (n) 必有路径

    2024年02月08日
    浏览(26)
  • Atcoder Beginner Contest 324 G Generate Arrays 题解-Treap

    为了更好的阅读体验,请点击这里 题目链接 套上平衡树板子就能做的很快的题,然后因为是指针存树,因此交换只需要把序列大小较小的挨个拿出来插到相应的地方即可。复杂度 (O(N log^2 N)) 。 但是一定要记住 不可以直接使用 std::swap 交换包含带有指针的类的实例(如代码

    2024年02月08日
    浏览(31)
  • AtCoder Beginner Contest 302 H. Ball Collector 题解 可撤销并查集

    为了更好的阅读体验,请单击这里 AtCoder Beginner Contest 302 H. Ball Collector 题意跳过。 可以视作将 (a_i, b_i) 之间连了一条边,然后 (a_i, b_i) 之间只能选一个等价于对于一条边只能选择其一个端点。那么对于只包含树的联通块而言,如果都选择儿子节点,那么会有一个根节点无

    2024年02月06日
    浏览(24)
  • Atcoder Beginner Contest 321 G - Electric Circuit 题解 - 状压dp | 指定最低位

    为了更好的阅读体验,请点击这里 题目链接:G - Electric Circuit 看到了 (N) 的数据范围,因此是显然的状压 dp。 不妨设 (f_S) 为仅使用 (S) 集合中的所有点,能够连成恰好 (1) 个连通块的方案数。 (g_S) 为仅使用 (S) 集合中的所有点的方案数,其中 (cntr(S)) 在 (S) 中为

    2024年02月05日
    浏览(37)
  • AtCoder Beginner Contest 341

    给定 (n) ,输出 (n) 个 (0) 和 (n+1) 个 (1) 交替的字符串。 (101010...) 循环输出即可。 神奇的代码 货币兑换。 (A) 国货币每 (x_a) 钱可兑换 (B) 国货币 (y_a) 钱。 (B) 国货币每 (x_b) 钱可兑换 (C) 国货币 (y_b) 钱。 ... 给定你拥有的每国货币钱数和兑换规则,依次兑换

    2024年02月19日
    浏览(19)
  • AtCoder Beginner Contest 326

    100楼层,一次可以上最多两层,或下最多三层。 给定两楼层,问能否一次到达。 比较大小,然后判断其差是是不是在 (2) 或 (3) 内即可。 神奇的代码 给定一个 (n) ,问不小于 (n) 的形如 (326) 的数字是多少。 形如 (326) 的数字,即数位有 (3) ,且百位 (times) 十位

    2024年02月08日
    浏览(22)
  • AtCoder Beginner Contest 314

    怎么好多陌生单词 审核怎么这么逆天,半小时还没审完 给定 (pi) 的值以及数 (n) ,要求保留 (n) 位小数输出,不四舍五入。 字符串形式储存然后截取末尾即可。 神奇的代码 (n) 个人玩轮盘赌游戏,简单说就是一个转盘有 (37) 个数字以及一个箭头,箭头会等概率停在某

    2024年02月13日
    浏览(28)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包