链接:

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. Java开发笔记(一百一十四)利用Socket传输文本消息

    前面介绍了HTTP协议的网络通信,包括接口调用.文件下载和文件上传,这些功能固然已经覆盖了常见的联网操作,可是HTTP协议拥有专门的通信规则,这些规则一方面有利于维持正常的数据交互,另一方面不可避免地 ...

  2. Django中的admin

    1.基本知识 在用Django框架写了一个网站之后,我们添加数据大概有两种方式: 1.在连接的数据库中添加数据 2.登录admin,进入后台添加数据 创建一个Django项目后,我们在url.py中会 ...

  3. tensorboard 拒绝访问解决方法

    打开Anaconda Prompt,切换到TensorFlow环境(activate tensorflow) 切换成功之后,输入tensorboard --logdir='路径' 注意:--logdi ...

  4. JAVA day1 基础知识

    一.windows命令 dir:查看文件 cd:打开文件 二.java的编译和运行 编译: javac 源文件名 一个类编译后会对应一个.class文件 运行: java 类名 三.类 一个源文件内可 ...

  5. spring boot 拦截 以及Filter和interceptor 、Aspect区别

    一.通过Filter这个大家很熟悉了吧,这是java规范的一个过滤器,他会拦截请求.在springboot中一般有两种配置方式.这种过滤器拦截并不知道你用的是哪一个Controller处理也不知道你用 ...

  6. 14-3 SQL Server基本操作

    SQL Server安装默认新建四个系统数据库 1.master数据库 Master数据库时SQL Server中最重要的数据库.它记录SQL Server实例的所有系统级信息,包括实例范围的元数据. ...

  7. centos7.5 离线安装ntp服务

    安装 #检查rpm包 rpm -qa | grep ntp #从https://pkgs.org/download/ntp 下载rpm包 ntp-4.2.6p5-28.el7.centos.x86_6 ...

  8. C# 连接SQLServer数据库自动生成model类代码

    Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Threading ...

  9. Linux系统内核正式进入5.0版本时代

    知名Linux内核开发人员兼维护人员Greg Kroah-Hartman今天宣布,Linux Kernel 4.20内核分支已经结束并督促用户尽快升级至更新的内核分支. Linux Kernel 4. ...

  10. vue入门模板——只需一个html

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...