uva 10276 / pc 110908
黑书上说用二分图的知识来解,但我想不出来,只好找规律
发现,一条柱时为1,两条柱时为4。三条柱时为8。。
这些1,3,7,11的数字加1后,都是下一条柱的最底部的数字,而且一条柱的数字之和总是按照这样的规律。1^2,2^2,3^2,4^2......
所以。。
#include <iostream>
#include <cstdio>
using namespace std; int ans[];
int upg[];
int main(){
upg[]=;
for(int i=;i<=;i++){
int anst=-;
for(int p=;p<=i;p++){
upg[p]=i*i-upg[p];
anst=max(anst,upg[p]);
}
ans[i]=anst;
upg[i+]=anst+;
}
int T;
scanf("%d",&T);
while(T--){
int n;
scanf("%d",&n);
printf("%d\n",ans[n]);
}
return ;
}
uva 10276 / pc 110908的更多相关文章
- (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO
http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...
- ACM训练计划step 1 [非原创]
(Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...
- 算法竞赛入门经典+挑战编程+USACO
下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...
- PC/UVa 题号: 110106/10033 Interpreter (解释器)题解 c语言版
, '\n'); #include<cstdio> #include<iostream> #include<string> #include<algorith ...
- The Trip PC/UVa IDs: 110103/10137, Popularity: B, Success rate: average Level: 1
#include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...
- 挑战编程PC/UVa Stern-Brocot代数系统
/* Stern-Brocot代数系统 Stern-Brocot树是一种生成所有非负的最简分数m/n的美妙方式. 其基本方式是从(0/1, 1/0)这两个分数开始, 根据需要反复执行如下操作: 在相邻 ...
- PC/UVa 题号: 110105/10267 Graphical Editor (图形化编辑器)题解
#include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...
- PC/UVa 题号: 110104/706 LC-Display (液晶显示屏)题解
#include <string> #include <iostream> #include <cstring> #include <algorithm> ...
- Minesweeper PC/UVa IDs: 110102/10189, Popularity: A,Success rate: high Level: 1
#include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...
随机推荐
- CMMI的SG/GG概念区别与SP/GP概念的区别
每一个 “流程区域” 会细分为多个子目标.若该子目标只对应单一的流程区域,称为 “特定目标(Specific goal)”:若子目标会涵跨多个流程区域,则称为 “一般目标(Generic goal)” ...
- Rancher 2:添加 NFS client provisioner 动态提供 Kubernetes 后端存储卷
一.前提说明 1.说明: NFS client provisioner 利用 NFS Server 给 Kubernetes 作为持久存储的后端,并且动态提供PV. 默认 rancher 2 的存储类 ...
- 解决IE不支持Data.parse()的问题
Date.parse()函数的返回值为Number类型,返回该字符串所表示的日期与 1970 年 1 月 1 日午夜之间相差的毫秒数. var nowtime = "2017-02-08&q ...
- 7.Flask-上传文件和访问上传的文件
1.1.上传文件和访问上传的文件 upload_file_demo.py from flask import Flask,request,render_template import os from ...
- 树莓派-基于raspivid实现拍视频
经过上一篇<<树莓派-安装摄像头模块>>之后 想要用摄像头模块拍一段视频的话,可以从命令行运行 raspivid 工具.下面这句命令会按照默认配置(长度5秒,分辨率1920x1 ...
- 导入不同业务数据通过Excel实现
很多公司都用到了老系统移植到新系统,数据自然也需要迁移,这个解决方案之一就是使用Excel文件导入. 结合公司实现,然后简单写了个Demo. (PS:去找朋友本想着花几十分钟弄出来炫耀一波,结果花了三 ...
- inline-block默认间距解决方法
方法一: 父元素设置font-size: 0; 行内块元素有文字时再在该元素上设置font-size 方法二: 父元素设置word-spacing为负 方法三: Inline-block 元素浮 ...
- 【原创】你知道Oracle 10G能存多少数据吗
昨天晚上在看Oracle 10G联机文档中关于bigfile tablespaces的描述(引用1),发现了关于Oracle存储极限的简单描述.bigfile tablespaces的存在,让Orac ...
- Visual Studio Code 插件推荐
Path Intellisense - 路径补全 HTML Snippets - HTML 标记增强 Markdown+Math - Markdown 增强(数学表达式) vscode-icons - ...
- 不能访问windows installer 服务,可能你在安全模式下运行 windows ,或者windows installer
windows installer服务解决方案 很多朋友在安装MSI格式的文件包时,经常会遇到windows installer出错的情况,有如下几种现象: 1.所有使用windows install ...