SGU 163.Wise King
一道题目长的水题。。。。
总结就一句话,给出n个(-3~3)的数,一个数m,取任意个数是使这些数的m次幂之和最大。
code
#include <iostream>
#include <cmath>
using namespace std;
int n, m, x;
int g[7];
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> x, g[x + 3]++;
int ans = 0;
for (int i = 0; i <= 6; i++) {
int tem = int (pow (i - 3, m) );
if (tem > 0) ans += tem*g[i];
}
cout<<ans;
return 0;
}
SGU 163.Wise King的更多相关文章
- sgu 147. Black-white king 思路 坑 难度:1
147. Black-white king time limit per test: 0.25 sec.memory limit per test: 4096 KB input: standard i ...
- SGU 147.Black-white king
时间限制:0.25s 空间限制:4M 题意: 在一个N*N(N <= 106)的棋盘上,有三个棋子:黑王.白王.黑白王,它们的行走方式一致,每秒向8个方向中的任意一个行走一步. 现在黑王和白王想 ...
- SGU 分类
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...
- 今日SGU 5.8
SGU 109 题意:一个n*n的矩形,起点在1,1然后每次给你一个操作,走ki步,然后你可以删除任意一个点这次步走不到的,删了就不能再走了,然后问构造这种操作,使得最后删除n*n-1个点 剩下一个点 ...
- 状压DP SGU 223 Little Kings
题目传送门 /* 题意:n*n的矩阵,放置k个king,要求king互相不能攻击,即一个king的8个方向都没有另外的king,求方案个数 状态压缩DP:dp[i][num[j]][s] 代表在第i行 ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- php使用CI发送qq和163邮件
1.需求 发送邮件 2.介绍 使用CI框架的email类库发送邮件,这里演示QQ和163 3.163使用教程 a.先去163邮件开启smtp邮件. b.在CI的控制器里写下面的代码 $this-> ...
- BZOJ 1087: [SCOI2005]互不侵犯King [状压DP]
1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 3336 Solved: 1936[Submit][ ...
- ubuntu修改163软件源
cd /etc/apt cat sources.list sudo su root sudo echo '' > sources.list nano sources.list 复制163软件源 ...
随机推荐
- 配置Myeclipse中的项目部署到服务器,报the selected server is enabled, but is not configured properly.
the selected server is enabled, but is not configured properly. deployment to it will not be permitt ...
- MyEclipse 设置字体
过了好几年,又开始用myeclipse 都忘了, 这里贴图用于记录 1.打开window - preferences . 2.打开General-Appearance-Colors and Fon ...
- poj 1011 搜索减枝
题目链接:http://poj.org/problem?id=1011 #include<cstdio> #include<cstring> #include<algor ...
- nginx简单双机热备:backup参数的使用
nginx简单双机热备:backup参数的使用 nginx简单双机热备:backup参数的使用
- 不要在精确计算中使用float和double类型
http://blog.csdn.net/androiddevelop/article/details/8478879 一 问题描述 float和double类型不能用于精确计算,其主要目的是为了科 ...
- IOS 多个ImageView图片层叠透明区域点击事件穿透
经常用到多个透明图片层叠,但又需要获取不同图片的点击事件,本文实现图片透明区域穿透点击事件 实现人体各个部位点击 - (BOOL) pointInside:(CGPoint)point withEve ...
- SQL server数据库中的DateTime类型出现的问题
我们知道这个SQL server数据库中的DateTime类型是数据库应用开发中经经常使用到的一种数据类型.而C#语言中也有DateTime类型,尽管二者都是用来描写叙述时间的,可是它们的默认值是不同 ...
- 基于amoeba实现mysql数据库的读写分离/负载均衡
一.Amoeba的简述:[来自百度百科] Amoeba是一个以MySQL为底层数据存储,并对应用提供MySQL协议接口的proxy.它集中地响应应用的请求,依据用户事先设置的规则,将SQL请 ...
- 关于MySQL的各种总结
https://blog.atime.me/note/mysql-summary.html 总结使用MySQL过程中遇到的各种问题和一些有用的资源,配置等等.将之前的若干篇零散的文章汇总到一起,备忘. ...
- iOS-UIResponse之事件响应链及其事件传递
UIResponse之事件响应链及其事件传递 我们的App与用户进行交互,基本上是依赖于各种各样的事件.一个视图是一个事件响应者,可以处理点击等事件,而这些事件就是在UIResponder类中定义的. ...