LightOJ - 1294 - Positive Negative Sign(规律)
链接:
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(规律)的更多相关文章
- 1294 - Positive Negative Sign(规律)
1294 - Positive Negative Sign PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...
- light oj 1294 - Positive Negative Sign
1294 - Positive Negative Sign PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...
- lightoj--1294--Positive Negative Sign(水题,规律)
Positive Negative Sign Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu ...
- 阳/阴性预测值Positive/negative Predictive Value(推荐AA)
sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频教程) https://study.163.com/course/introduction.htm?courseId=1005269003&am ...
- 智课雅思短语---二、exert positive/ negative effects on…
智课雅思短语---二.exert positive/ negative effects on… 一.总结 一句话总结:对…产生有利/不利的影响 1.the advantages far outweig ...
- 零宽断言 -- Lookahead/Lookahead Positive/Negative
http://www.vaikan.com/regular-expression-to-match-string-not-containing-a-word/ 经常我们会遇到想找出不包含某个字符串的文 ...
- LightOJ 1245 数学题,找规律
1.LightOJ 1245 Harmonic Number (II) 数学题 2.总结:看了题解,很严谨,但又确实恶心的题 题意:求n/1+n/2+....+n/n,n<=2^31. ...
- LightOJ 1369 Answering Queries(找规律)
题目链接:https://vjudge.net/contest/28079#problem/P 题目大意:给你数组A[]以及如下所示的函数f: long long f( int A[], int n ...
- LightOJ - 1369 - Answering Queries(规律)
链接: https://vjudge.net/problem/LightOJ-1369 题意: The problem you need to solve here is pretty simple. ...
随机推荐
- 阿里的Netty知识点你又了解多少
前言 Netty 是一个可以快速开发网络应用程序的 NIO 框架,它大大简化了 TCP 或者 UDP 服务器的网络编程.Netty 的简易和快速开发并不意味着由它开发的程序将失去可维护性或者存在性能问 ...
- day41——数值类型、完整性约束
day41 数值类型 整数类型 有符号的设置 mysql> create table t1(id tinyint); # 默认有符号,即数字前有正负号 无符号的设置 mysql> crea ...
- day20——规范化目录
day20 为什么要有规范化目录 可读性高: 不熟悉这个项目的代码的人,一眼就能看懂目录结构,知道程序启动脚本是哪个,测试目录在哪儿,配置文件在哪儿等等.从而非常快速的了解这个项目. 可维护性高: 定 ...
- mysql_select 单表查询
select * *代表全部 查询多个字段 select 字段1,字段2,字段3 聚合函数 count(*) 统计 select count(*) ...
- Centos7部署开源聊天软件rocket.chat
一.部署rocket.chat 1.看官方文档部署,很简单,一步一步跟着部署即可 注意:需要部署节点需要联网主要是yum方式 https://rocket.chat/docs/installation ...
- Unity项目 - MissionDemolition 愤怒的小鸟核心机制
目录 游戏原型 项目演示 绘图资源 代码实现 注意事项 技术探讨 参考来源 游戏原型 爆破任务 MissionDemolition 是一款核心机制类似于愤怒的小鸟的游戏,玩家将用弹弓发射炮弹,摧毁城堡 ...
- 实现负载均衡的小demo
首先我们先来了解负载均衡: 负载均衡是为了缓解网络压力的,服务器端进行扩容的重要手段 实现有两种方式:硬件F5 . 软件nginx.Dubbo 为了实现负载均衡的原理,我们基于以下两篇随笔继 ...
- LifeGame
LifeGame 用例说明&用例图 用例名: 设置细胞颜色 说明 用户可以根据自己的喜好来设置细胞的颜色 主事件流 在菜单出点击需要的颜色游戏检测到菜单的返回的颜色更改细胞的颜色,最后显示出来 ...
- js 数组的深度拷贝 的四种实现方法
首先声明本人资质尚浅,本文只用于个人总结.如有错误,欢迎指正.共同提高. --------------------------------------------------------------- ...
- Python学习日记(二十五) 接口类、抽象类、多态
接口类 继承有两种用途:继承基类的方法,并且做出自己的改变或扩展(代码重用)和声明某个子类兼容于某基类,定义一个接口类interface,接口类中定义了一些接口名(就是函数名)且并未实现接口的功能,子 ...