美文网首页
每日总结-第五十四天-51nod刷题

每日总结-第五十四天-51nod刷题

作者: SamiraG | 来源:发表于2020-06-21 00:16 被阅读0次

题外

第一次用51nod刷题,wtcl,只能刷最简单的。

3056: 小明爱数列

#include <iostream>
#include <vector>
using namespace std;

void print(vector<int> num)
{
    cout << num.size() << endl;
    vector<int>::iterator it;
    for(it=num.begin();it!=num.end();it++)
    {
        if(it != num.begin())
            cout << " ";
        cout<<*it;
    }
    cout << endl;
}

int main() {
    int m, n;
    cin >> n >> m;
    vector<int> num;
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        num.push_back(temp);
    }
    for(int i = 0; i < m; i++)
    {
        char op;
        cin >> op;
        if(op == 'D')
        {
            int x;
            cin >> x;
            if(x >= num.size())
                continue;
            num.erase(num.begin()+x);
        }
        else
        {
            int x, y;
            cin >> x >> y;
            if(x >= num.size())
                num.push_back(y);
            else
                num.insert(num.begin()+x, y);
        }
    }
    print(num);
    return 0;
}

3034: 矩形的数量V2

这道题因为数据大小问题出错了很多次...

#include <iostream>
#include <math.h>
using namespace std;

int main() {
    long m, n;
    cin >> m >> n;
    if(m < n)
    {
        long temp = n;
        n = m;
        m = temp;
    }
    long total = ((1 + n) * n) / 2 + n * (m - n);
    long mod = 1e9+7;
    cout << total % mod << endl;
    return 0;
}

相关文章

  • 每日总结-第五十四天-51nod刷题

    题外 第一次用51nod刷题,wtcl,只能刷最简单的。 3056: 小明爱数列 3034: 矩形的数量V2 这道...

  • PTA刷题总结-Part 3 数据结构与算法

    PTA刷题总结-Part 1 基础部分PTA刷题总结-Part 2 模拟与数学问题PTA刷题总结-Part 3 数...

  • PTA刷题总结-Part 2 模拟与数学问题

    PTA刷题总结-Part 1 基础部分PTA刷题总结-Part 2 模拟与数学问题PTA刷题总结-Part 3 数...

  • Manacher 马拉车算法计算回文子串

    最近开始刷算法题,在刷第五题的时候,看到一个有意思的算法,总结一下 计算回文子串,首先简单的有 暴力破解法,就是挨...

  • 刷题总结

    以前学习总觉得听懂了就会了,一直到现在都觉得。这几天忙考试,想着刷题吧,刷一个错一个,有因为题目没看清楚的但大...

  • 人生跃迁记录史

    早:刷题,图推,总结 中:资分刷题 晚:刷题总结,申论复习1小时 睡前回顾当天所需,学到了记住了什么清楚明白 高频...

  • Goal

    就当是一个刷题日记 每日三道题

  • 百人百天训练营[6]效率提升

    20191003 每日复盘 今天早上的基金第五套题是我刷的效率最高的一次了,整套刷完加订正,包括第二次的直接刷到9...

  • Leetcode刷题日记(五)

    刷题的第五周了,这周开始刷Medium的题,每天2-3题吧 目前进度: 68/100 1.2020/04/13 a...

  • 刷题总结(1)

    题目描述 给出一个数n,求1到n中,有多少个数不是2 5 11 13的倍数。 输入描述 本题有多组输入每行一个数n...

网友评论

      本文标题:每日总结-第五十四天-51nod刷题

      本文链接:https://www.haomeiwen.com/subject/ezpnxktx.html