http://codeforces.com/contest/1260/problem/A

A. Heating
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Several days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house.

Your house has nn rooms. In the ii-th room you can install at most cici heating radiators. Each radiator can have several sections, but the cost of the radiator with kk sections is equal to k2k2 burles.

Since rooms can have different sizes, you calculated that you need at least sumisumi sections in total in the ii-th room.

For each room calculate the minimum cost to install at most cici radiators with total number of sections not less than sumisumi.

Input

The first line contains single integer n (1≤n≤10001≤n≤1000) — the number of rooms.

Each of the next n lines contains the description of some room. The i-th line contains two integers cici and sumisumi (1≤ci,sumi≤1041≤ci,sumi≤104) — the maximum number of radiators and the minimum total number of sections in the i-th room, respectively.

Output

For each room print one integer — the minimum possible cost to install at most cici radiators with total number of sections not less than sumisumi.

Example
input
4
1 10000
10000 1
2 6
4 6
output
100000000
1
18
10

  题意:

    n个测试组

    每组给定 n(最多可用的暖气装置个数)sum(所有暖气装置最少应达到的零件数总和)

    每个暖气装置的cost为零件数的平方

    求最少cost总和

  解决:

    用尽量多的装置个数,尽量均分所有零件。

  代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include <vector>
#include <iterator>
#include <utility>
#include <sstream>
#include <limits>
#include <numeric>
#include <functional>
using namespace std;
#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))
//#define sort(a,n,int) sort(a,a+n,less<int>()) #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef char ch;
typedef double db; const double PI=acos(-1.0);
const double eps=1e-6;
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=100+10; int main()
{
int t = 0;
int c , sum ;
cin >>t;
while(t--)
{
cin >>c >>sum;
int sum1 = (sum/c+1)*(sum/c+1)*(sum%c) ;
int sum2 = (sum/c)*(sum/c)*(c-sum%c);
cout <<sum1 + sum2 <<endl;
}
return 0;
}

A. Heating -Codeforces Round 77 (Div. 2)的更多相关文章

  1. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  2. [题解] Codeforces Round #549 (Div. 2) B. Nirvana

    Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit ...

  3. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  4. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  5. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  6. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  7. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  8. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  9. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  10. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

随机推荐

  1. C#网络编程(六)----Socket编程模型

    简介 Socket(套接字)是计算机网络中的一套编程接口,是网络编程的核心,它将复杂的网络协议封装为简单的API,是应用层(HTTP)与传输层(TCP)之间的桥梁. 应用程序通过调用Socket AP ...

  2. python基础—基本数据类型—数字,字符串,列表,元组,字典

    1.运算符 (1)基本运算符 +  加法   -   减法 *   乘法 /   除法 **   幂 //   取整(除法) %   取余(除法) (2)判断某个东西是否在某个东西里面包含 in no ...

  3. DeepSeek MOE 代码实现

    前置知识: PyTorch 基础函数操作整理 1. topk 操作 功能: torch.topk 用于返回输入张量中指定维度上的前 k 个最大元素及其对应的索引. 示例代码: import torch ...

  4. Tauri2.0-DeepSeek电脑端Ai对话|tauri2+vite6+deepseek流式ai聊天系统

    重磅新作tauri2.0+vue3.5+deepseek+arco桌面客户端ai流式输出聊天对话系统. tauri2-vue3-deepseek:桌面端ai聊天对话,基于Tauri2.x+Vite6集 ...

  5. 开源项目丨一文详解一站式大数据平台运维管家ChengYing如何部署Hadoop集群

    课件获取:关注公众号"数栈研习社",后台私信 "ChengYing" 获得直播课件 视频回放:点击这里 ChengYing开源项目地址:github 丨 git ...

  6. APIO2025 一堆题解

    APIO2025 一堆题解 图论 AtCoder Xmas Contest 2024 A 答案永远是\(1\),6 NWRRC 2015 Graph 考虑不加边,怎么找字典序最小的拓扑序,就维护一个小 ...

  7. NOIP 2024 游寄

    别让我担心 派蒙可爱! 天气晴 风平浪静 沙滩上混乱的脚印 钓鱼竿 两份孤单 会飞的落汤鸡 是故事的开局 青橙紫绿 留影机塞满了回忆 可我却无比思念 遇见你的那一集 才发现我们早已 走了很远很远 多少 ...

  8. 使用 Firefox (火狐)浏览器 必开的配置

    首先,在网址输入框中输入 about:config 进入浏览器配置页面 设置打开书签的时候在新标签页打开 然后搜索 browser.tabs.loadBookmarksInTabs 并将它的值改为tr ...

  9. TypeScript枚举类型应用:前后端状态码映射的最简方案

    介绍 这篇文章来谈一下 TypeScript 中的枚举类型(Enum)以及一些最佳实践.事情的起因是这样的,今天看到自己之前写的一段代码,感觉不是很好,于是想优化一下,期间用到了枚举类型,遂记录一下. ...

  10. C++多线程的转载

    转载自 http://www.cnblogs.com/quincyhu/p/5884361.html 例子也请访问这个博客的页面 技术要点 //使用 -lpthread 库编译下面的程序: g++ t ...