Positive Negative Sign<大水题>

本文介绍了一种符号化求和算法,该算法接受两个整数n和m作为输入,并将前n个自然数按特定规则分配正负号,然后计算这些数的总和。具体规则为:首先取前m个整数并赋予负号,接下来的m个整数赋予正号,依此类推。文章还提供了一个示例程序,用于演示如何根据输入的n和m来计算最终的符号化求和结果。

Description

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 mintegers 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.

Input

Input starts with an integer T (≤ 10000), denoting the number of test cases.

Each case starts with a line containing two integers: n and m (2 ≤ n ≤ 109, 1 ≤ m). And you can assume that n is divisible by 2*m.

Output

For each case, print the case number and the summation.

Sample Input

2

12 3

4 1

Sample Output

Case 1: 18

Case 2: 2

#include<cstdio>
int main()
{
	long long t,cut=0;
	scanf("%lld",&t);
	while(t--)
	{
		cut++;
		long long n,m;
		scanf("%lld%lld",&n,&m);
		printf("Case %lld: %lld\n",cut,n/2*m);
	}
	return 0;
}


### HTML代码的功能和样式设计解析 #### 1. 模型性能指标的展示方式 在HTML中,模型性能指标通常通过表格或列表的形式呈现。例如,使用`<table>`标签可以清晰地展示准确率(Accuracy)、精确率(Precision)、召回率(Recall)以及F1分数等指标[^4]。以下是一个示例: ```html <table border="1"> <tr> <th>指标</th> <th>值</th> </tr> <tr> <td>准确率 (Accuracy)</td> <td>0.85</td> </tr> <tr> <td>精确率 (Precision)</td> <td>0.90</td> </tr> <tr> <td>召回率 (Recall)</td> <td>0.87</td> </tr> <tr> <td>F1分数</td> <td>0.88</td> </tr> </table> ``` 上述表格通过`<table>`标签定义结构,`<tr>`表示行,`<td>`表示数据单元格,`<th>`表示表头单元格。 #### 2. 混淆矩阵的展示方式 混淆矩阵可以通过HTML中的`<canvas>`标签结合JavaScript绘制,或者直接使用表格形式展示。以下是表格形式的混淆矩阵示例: ```html <table border="1"> <tr> <th></th> <th colspan="2">预测值</th> </tr> <tr> <th rowspan="2">真实值</th> <th>Positive</th> <th>Negative</th> </tr> <tr> <td>Positive</td> <td>TP: 90</td> <td>FN: 10</td> </tr> <tr> <td>Negative</td> <td>FP: 5</td> <td>TN: 95</td> </tr> </table> ``` 混淆矩阵的核心指标包括: - TP (True Positive): 真实值为正类且预测值也为正类的数量。 - TN (True Negative): 真实值为负类且预测值也为负类的数量。 - FP (False Positive): 真实值为负类但预测值为正类的数量。 - FN (False Negative): 真实值为正类但预测值为负类的数量。 #### 3. 数据表格的展示方式 数据表格通常使用`<table>`标签来实现。以下是一个简单的数据表格示例: ```html <table border="1"> <tr> <th>特征1</th> <th>特征2</th> <th>特征3</th> <th>标签</th> </tr> <tr> <td>1</td> <td>0</td> <td>1</td> <td>1</td> </tr> <tr> <td>0</td> <td>1</td> <td>0</td> <td>0</td> </tr> </table> ``` 此表格展示了训练数据的特征和标签。特征值经过预处理,用`1`和`0`分别表示“好”、“是”、“高”和“坏”、“否”、“低”[^2]。 #### 4. 样式设计 为了提升用户体验,可以通过CSS对HTML内容进行样式设计。例如,调整字体、颜色和布局以使数据更易于理解。以下是一个CSS示例: ```css table { width: 50%; border-collapse: collapse; margin: 20px auto; } th, td { padding: 10px; text-align: center; border: 1px solid #ddd; } th { background-color: #f4f4f4; color: #333; } tr:nth-child(even) { background-color: #f9f9f9; } tr:hover { background-color: #f1f1f1; } ``` 上述CSS规则定义了表格的宽度、边框样式、单元格填充、背景颜色和鼠标悬停效果。 ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值