链接:

https://vjudge.net/problem/LightOJ-1294

题意:

Given two integers: n and m and n is divisible by 2m, you have to write down the first n natural numbers in the following form. At first take first m integers and make their sign negative, then take next m integers and make their sign positive, the next m integers should have negative signs and continue this procedure until all the n integers have been assigned a sign. For example, let n be 12 and m be 3. Then we have

-1 -2 -3 +4 +5 +6 -7 -8 -9 +10 +11 +12

If n = 4 and m = 1, then we have

-1 +2 -3 +4

Now your task is to find the summation of the numbers considering their signs.

思路:

显然的公式, mm(n/(2*m))

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map> using namespace std;
typedef long long LL;
const int INF = 1e9; const int MAXN = 1e6+10;
const int MOD = 1e9+7; int main()
{
int t, cnt = 0;
int n, m;
scanf("%d", &t);
while(t--)
{
printf("Case %d: ", ++cnt);
scanf("%d%d", &n, &m);
printf("%lld\n", 1LL*m*m*(n/(2*m)));
} return 0;
}

LightOJ - 1294 - Positive Negative Sign(规律)的更多相关文章

  1. 1294 - Positive Negative Sign(规律)

    1294 - Positive Negative Sign   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...

  2. light oj 1294 - Positive Negative Sign

    1294 - Positive Negative Sign   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...

  3. lightoj--1294--Positive Negative Sign(水题,规律)

    Positive Negative Sign Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu ...

  4. 阳/阴性预测值Positive/negative Predictive Value(推荐AA)

    sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频教程) https://study.163.com/course/introduction.htm?courseId=1005269003&am ...

  5. 智课雅思短语---二、exert positive/ negative effects on…

    智课雅思短语---二.exert positive/ negative effects on… 一.总结 一句话总结:对…产生有利/不利的影响 1.the advantages far outweig ...

  6. 零宽断言 -- Lookahead/Lookahead Positive/Negative

    http://www.vaikan.com/regular-expression-to-match-string-not-containing-a-word/ 经常我们会遇到想找出不包含某个字符串的文 ...

  7. LightOJ 1245 数学题,找规律

    1.LightOJ 1245   Harmonic Number (II)   数学题 2.总结:看了题解,很严谨,但又确实恶心的题 题意:求n/1+n/2+....+n/n,n<=2^31. ...

  8. LightOJ 1369 Answering Queries(找规律)

    题目链接:https://vjudge.net/contest/28079#problem/P 题目大意:给你数组A[]以及如下所示的函数f: long long f( int A[], int n  ...

  9. LightOJ - 1369 - Answering Queries(规律)

    链接: https://vjudge.net/problem/LightOJ-1369 题意: The problem you need to solve here is pretty simple. ...

随机推荐

  1. Linux学习-基本命令文件操作

    终端 1.多个终端 连接linux的客户端可以理解为终端. 命令:tty查看终端 2.不同终端之间的通讯 [root@wyx wyx]# echo 123 > /dev/pts/1 把123发给 ...

  2. 为什么Apache Kafka如此受欢迎

    1.目标 今天,在这个Kafka教程中,我们将学习所有Kafka功能,如可扩展性,可靠性,耐用性,这些都说明了Kafka如此受欢迎的原因.我们将详细讨论Kafka的每个功能.但在那之前让我们明白什么是 ...

  3. DSP未来五大发展趋势

    在4G无线通信领域,数据吞吐量已经达到了3G时代的100到1000倍;在多媒体处理器领域,每天都有新的标准涌现出来;在更多其它DSP应用领域,密集的数据处理器需求不断给处理器设计团队带来新的挑战.随着 ...

  4. 【LEETCODE】58、数组分类,适中级别,题目:238、78、287

    package y2019.Algorithm.array.medium; import java.util.Arrays; /** * @ProjectName: cutter-point * @P ...

  5. 一行代码让3D翻转后的文本恢复清晰

    FlashPlayer10提供的3D功能有一个相当蛋疼的问题:只要设置过rotationX.rotationY或者rotationZ属性,显示对象里面的文字(尤其是设备字体,位图文本)就会一直处于模糊 ...

  6. 接口与DRF的安装

    接口 # 接口:url链接,通过向链接发送不同的类型请求与参数得到相应的响应数据​# 1.在视图层书写处理请求的 视图函数# 2.在路由层为视图函数配置 url链接 => 产生接口# 3.前台通 ...

  7. Unity的学习笔记(鼠标移动控制视角移动)

    using UnityEngine; public class MouseLook : MonoBehaviour { , MouseX = , MouseY = } //定义一个枚举,移动xy,或者 ...

  8. memcpy 速度测试

    1. 小米8代i5    3840X2160X4   7.77ms      即34Gbps

  9. Flutter Animation AnimatedBuilder

    Flutter AnimatedBuilder 创建动画的widget Key key, @required Listenable animation, @required this.builder, ...

  10. python day 9: xlm模块,configparser模块,shutil模块,subprocess模块,logging模块,迭代器与生成器,反射

    目录 python day 9 1. xml模块 1.1 初识xml 1.2 遍历xml文档的指定节点 1.3 通过python手工创建xml文档 1.4 创建节点的两种方式 1.5 总结 2. co ...