POJ 2209 The King(水~)
来源:互联网 发布:sm是什么体验 知乎 编辑:程序博客网 时间:2024/06/06 00:05
Description
第一个数是数列的长度,第二个数字是指数,第三行是数列,即真数。从数列中选择任意多个,使得他们每个求幂再求和最大
Input
第一个数是数列的长度,第二个数字是指数,第三行是数列
Output
输出最大幂和
Sample Input
3
3
2 -1 1
Sample Output
9
Solution
水题,注意指数奇偶
Code
#include<stdio.h>#include<math.h>int main(){ int n,m,a[300]; scanf("%d%d",&n,&m); for(int i=0;i<n;i++) scanf("%d",&a[i]); int res=0; if(m%2==0)//指数偶数则全加 { for(int i=0;i<n;i++) res+=(int)pow(a[i],m); } else if(m%2)//指数为奇数则加整数 { for(int i=0;i<n;i++) if(a[i]>0) res+=(int)pow(a[i],m); } printf("%d\n",res); return 0;}
0 1
- POJ 2209 The King(水~)
- POJ 2209 The King
- poj 2209 The King
- poj 2209 The King
- poj 2209 The King
- POJ 2209 The King(模拟)
- POJ 2209 The King(我的水题之路——n次方之和)
- POJ 2209The King 简单暴力
- poj 2209 The King【注:pow(int ,int )】
- POJ 2728 (Desert King)
- King is the king
- POJ 4489 The King’s Ups and Downs (区间DP)
- King POJ
- The king
- POJ 1364 King (差分约束)
- poj 1364 King(差分约束)
- POJ 1364 King(差分约束)
- POJ 1364 King (差分约束)
- aurelia 跨域问题
- ICMP (网际控制报文协议)
- leetcode 017 —— Letter Combinations of a Phone Number
- BOOST开发指南
- Kind Editor 编辑器 指定初始化模块
- POJ 2209 The King(水~)
- 王家林亲授《DT大数据梦工厂》大数据实战视频“Scala深入浅出实战经典” 第46讲视频、音频和PPT下载!
- JM配置文件Encoder.cfg中比较重要的几项
- 模仿大众点评过滤框
- CvMemStorage
- DrawerLayout Demo
- 欢迎使用CSDN-markdown编辑器
- iOS GCD使用
- LeetCode145 Binary Tree Postorder Traversal Java题解(递归 迭代)