简单题,但是为什么赛场上 WA 了呢?

弱化题目,设 \(n = k + 1\),发现只需要每一个数不取询问 \(k\) 次,通过前缀和得出。

再设 \(k + 1 \ | \ n\),发现只需要类似分块即可解决。

回到原题,最后的一部分如何计算?我们可以对 \([n - k, n]\) 这个区间做询问,但是对于已经计算的数不再去除。把每一个得到的和减去前面已经计算的数的和就是真实的和,类似的也能计算出。

询问次数刚好为 \(n\),时间复杂度为 \(\mathcal{O}(n)\),可以通过此题。

[AT_abc313_d] Odd or Even的更多相关文章

  1. [LeetCode] Odd Even Linked List 奇偶链表

    Given a singly linked list, group all odd nodes together followed by the even nodes. Please note her ...

  2. Odd Even Linked List

    Given a singly linked list, group all odd nodes together followed by the even nodes. Please note her ...

  3. LeetCode 328. Odd Even Linked List

    Given a singly linked list, group all odd nodes together followed by the even nodes. Please note her ...

  4. tr:even 与tr:odd

    :even匹配所有索引值为偶数的元素,从 0 开始计数查找表格的1.3.5...行(即索引值0.2.4...)<table> <tr><td>Header 1< ...

  5. Leetcode Odd Even Linked List

    Given a singly linked list, group all odd nodes together followed by the even nodes. Please note her ...

  6. CSS3伪类选择器:nth-child()(nth-child(odd)/nth-child(even))

    nth-child(odd):奇数 nth-child(even):偶数 使用时,如果是精确到数字时,切记是从同一级别的元素开始计算,而不是指定某个类才开始计算. 比如: <li>< ...

  7. [CareerCup] 5.6 Swap Odd and Even Bits 交换奇偶位

    5.6 Write a program to swap odd and even bits in an integer with as few instructions as possible (e. ...

  8. [Educational Codeforces Round 16]C. Magic Odd Square

    [Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...

  9. 328. Odd Even Linked List——多利用fake_head

    Given a singly linked list, group all odd nodes together followed by the even nodes. Please note her ...

  10. 越狱Season 1-Episode 12:Odd Man Out

    Season 1-Episode 12:Odd Man Out -Sorry to keep you waiting. 抱歉让你等了半天 -Oh, it's, uh, not a problem. 嗯 ...

随机推荐

  1. DataFrame.iterrows的一种用法

    import pandas as pd import numpy as np help(pd.DataFrame.iterrows) Help on function iterrows in modu ...

  2. github常见开源协议概括

    None / No License 默认协议,不允许他人复杂.分发.修改.使用,只能fork下来看 Apache License 2.0 允许个人使用.商业使用.复制.修改.分发,但是出了事作者免责, ...

  3. Openmv简明使用教程

    Openmv简明使用教程 写在前面 本教程主要目的是指明学习资源在哪,可以怎么学,不教具体怎么使用,因为没有什么教程比官网上的教程更详细了,希望大家看完这篇文章后,能对如何学习使用Openmv有一个清 ...

  4. Arduino从零开始的高手之路——初识Arduino

    初识Arduino 时隔若干年,重启Arduino入门教程~ Arduino自2005年推出以来,广受好评,如今已成为最热门的开源硬件之一.在全球最大的开源社区Github上,Arduino已经成为了 ...

  5. Altair官方文档——HyperMesh的使用与帮助

    1.1.3 启动 HyperMesh (1) On PC • 从起始菜单,选择 All Programs >Altair HyperWorks (version) > HyperMesh ...

  6. MongoDB入门实战教程(7)

    本系列教程目录: MongoDB入门实战教程(1) MongoDB入门实战教程(2) MongoDB入门实战教程(3) MongoDB入门实战教程(4) MongoDB入门实战教程(5) MongoD ...

  7. Edge 突然显示网站“不安全”的一个处理办法。

    Edge浏览器升级后,访问以前可以正常访问的网站,地址栏前红色提示"不安全",网页无法访问,一会弹出来提示说"证书可能未被验证". 在我们确认该网站是正常的情况 ...

  8. C# 添加一个具有自定义命名空间和相同类名的静态类:Console

    using CLRConsole = System.Console; namespace ExtensionMethodsDemo { public static class Console { pu ...

  9. java基础--抽象类、接口

    final(最终.修饰符) ## final关键字的用法: 1. final关键字修饰一个基本类型的变量时,该变量不能重新赋值,第一次的值为最终的. 2. fianl关键字修饰一个引用类型变量时,该变 ...

  10. listmap根据某字段进行合并

    public List<Map<String, Object>> mergeResult(List<Map<String, Object>> m1, L ...