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. UVW源码漫谈(一)

    博客园是个非常好的学习知识的地方,相信有很多人跟我一样,园龄3年,从博客园不知道拷了多少代码,看了多少博客,自己却一篇博客都没写过.真是罪过. 这次准备写几篇关于这个项目源码的阅读和理解的文章,大家一 ...

  2. 2022 电赛C题 巡线基础模块代码(带控制)

    巡线功能模块 from maix import camera, display, gpio, pwm class FindLine(): def __init__(self): self.THRESH ...

  3. 树结构Tree

    树结构 平衡顺序二叉树 通过平衡顺序二叉树查数据的时候,也就等同于二分查找的操作 Binary Search 2,3树 二三树 二三树有 node2 和 node3 两种节点,树的规则如图 2-3-4 ...

  4. From Small Not Perfect

    自己想实现一个共享文档,然后统计每个人每周做题的数量,然后还想到每个月的统计,每年的统计,哇,好复杂哈 所以我想先做一个Excel,然后开始使用,中间发现了问题,然后调整,修改. 当我做了这个Exce ...

  5. HarmonyOS NEXT仓颉开发语言实战案例:健身App

    各位好,今日分享一个健身app的首页: 这个页面看起比之前的案例要稍微复杂一些,主要在于顶部部分,有重叠的背景,还有偏移的部分.重叠布局可以使用Stack容器实现,超出容器范围的偏移可以使用负数间距来 ...

  6. http流量镜像

    http流量镜像 "流量镜像"是指将网络中的数据流量复制一份,并将这份复制流量发送到另一个目的地(如监控.分析或安全检测系统).这项技术常用于网络安全.故障排查.业务灰度发布等场景 ...

  7. django静态资源问题

    开发环境下 开发环境下 即settings.py中的配置项 DEBUG = True的情况. 这种情况下,django会默认帮我们处理静态文件会帮我们处理一些事情. 我们只需要少数配置即可 固定配置项 ...

  8. esbuild vs webpack

    先看提速效果 上图:使用默认设置(包括缩小和源映射)从头开始制作包含 10 个three.js库副本的生产包的时间.更多信息在这里. 我们当前用于 Web 的构建工具比esbuild速度可能慢 10- ...

  9. axios的post请求formData

    import qs from 'qs'; axios({ method: 'post', url: '/login', headers: { 'Content-Type': 'application/ ...

  10. Atcoders [AGC014D] Black and White Tree 题解

    AT_agc014_d [AGC014D] Black and White Tree 我们充分发扬人类智慧. 不难发现如果树根确定的情况下,先手会从叶子的父亲开始填,如果填到某两棵子树的白点中刚好是同 ...