Uva 1319 - Maximum 解题报告(数学)

告别GDI+!在WinForm中用SkiaSharp和SKControl重绘人脸识别结果(附完整源码) 本文详细介绍了如何从GDI+迁移到SkiaSharp,在WinForm中实现高性能的人脸识别结果绘制。通过对比GDI+和SkiaSharp的技术优势,提供了完整的源码示例和迁移指南,包括环境配置、基础绘图、人脸标注组件实现以及性能优化技巧。SkiaSharp凭借硬件加速、跨平台支持和现代图形特性,成为替代GDI+的理想选择。 阅读详情

1319 - Maximum

Time limit: 3.000 seconds

Let x1x2,..., xm be real numbers satisfying the following conditions:

a)
-$ {\frac{​{1}}{​{\sqrt{a}}}}$$ \le$xi$ \le$$ \sqrt{​{5}}$ ;
b)
x1 + x2 +...+ xm = b * $ \sqrt{​{a}}$ for some integers a and b (a > 0).

Determine the maximum value of xp1 + xp2 +...+ xpm for some even positive integer p.

Input 

Each input line contains four integers: mpab ( m$ \le$2000, p$ \le$12p is even). Input is correct, i.e. for each input numbers there exists x1x2,..., xm satisfying the given conditions.

Output 

For each input line print one number - the maximum value of expression, given above. The answer must be rounded to the nearest integer.

Sample Input 

1997 12 3 -318 
10 2 4 -1

Sample Output 

189548 
6

    解题报告:首先,这个式子不是太好看,我们可以将两个式子都乘以根号a,那么-1$ \le$xi*$ \sqrt{​{5}}$$ \le$a,x1*$ \sqrt{​{5}}$ + x2*$ \sqrt{​{5}}$ +...+ xm*$ \sqrt{​{5}}$ = ab。

    为了使其的p次方和最大,p又是偶数,我们可以让一部分x*$ \sqrt{​{5}}$的值为-1,一部分为a,最后一个x的范围只要在-1到a间就可以了。m最大2000,直接枚举,然后计算,最终结果除以$ \sqrt{​{5}}$^p。代码如下:

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

void work(int m,int p,int a,int b)
{
    double res=0;
    for(int i=0;i<m;i++)
    {
        int last=a*b+i-(m-i-1)*a;
        if(last>=-1 && last<=a)
        {
            res+=i;
            res+=pow((double)last,p);
            res+=(double)(m-i-1)*pow((double)a,p);
            res/=pow((double)a, p/2.0);
            break;
        }
    }
    printf("%d\n", (int)(res+0.5));
}

int main()
{
    int m,p,a,b;

    while(~scanf("%d%d%d%d",&m,&p,&a,&b))
        work(m,p,a,b);
}

uva 1319 Maximum(贪心) 题目连接:2911 - Maximum 题目大意:给出m, p, a, b,然后xi满足题目中的两个公式, 要求求的 xp1 + xp2 +...+ xpm 的最大值。 解题思路:可以将x1 + x2 +...+ xm = b *  两端同时乘以根号a去计算。然后按照贪心的思想去计算。 #include #include int l, r; double m, p, a 阅读详情

相关推荐

UVA 1319 - Maximum(数论+贪心)

题目链接:1319 - Maximum 同这篇:

Remilia's 1385

UVALive 2911 Maximum

Let x1, x2, … , xm be real numbers satisfying the following conditions: a)- 1/√a ≤ xi ≤√a; b) x1 + x2 + … + xm = b ∗√a for some integers a and b (a > 0). Determine the maximum value of x p 1 + x

peach_yang的博客 332

【排列组合】UVALive - 6926 Maximum Score

Problem Decription 给你T组测试数据,给你n组数,每组数包含data, num,代表data这个数有num个。问你怎么排列这些数,求出最大的分数(如何求分数,一个数的左边递减个数包括相等 和 右边递减个数包括相等的和 加上 1(本身)就是该点的分数,但你要求出所有数的分数和)。求出最大分数一共有多少种组合 思路:从小到大排序一定是最大的分数和。因为(只要这串数保持弧形)所以从小

ACMer 梁剑锋 的博客 320

UVALive - 2911 Maximum

#include #include int main() { int m, p, a, b; while (scanf("%d%d%d%d", &m, &p, &a, &b) != EOF) { int temp = a * b, cnt = 0; double num = pow(sqrt(a), p); for (int i = 1; i < m; i++) tem

Bingo 1820

训练指南第二章-基础问题

训练指南第二章-基础问题 P170 2/4 Problem A UVA 10943 How do you add? 1/2 Problem B UVA 10780 Again Prime? No Time. 1/1 Problem C UVA 10892 LCM Cardinality 1/4 P...

weixin_33726943的博客 177

UVAlive 2911 Maximum(贪心)

Let x1, x2,..., xm be real numbers satisfying the following conditions: a)-xi ;b)x1 + x2 +...+ xm = b *  for some integers a and b (a > 0). Determine the maximum value of xp1 + xp2 +...+ xpm for

Remilia's 2279

Uva 1315 - Crazy tea party 解题报告(找规律)

1315 - Crazy tea party Time limit: 3.000 seconds n participants of �crazy tea party� sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minu

SF-_- 的 ACM 博客 3663

POJ 3101 Astronomy 解题报告(大数乘法+分数最小公倍数)

题目大意:给出n的行星的周期,问n个行星在一条直线上的周期。     解题报告:懒……就直接用Java大数。当然,时间垫底 import java.math.BigInteger; import java.util.Scanner; public class Main { static int[] a = new int[1010]; static Scanner cin = new S

SF-_- 的 ACM 博客 3424

POJ 1166 The Clocks 解题报告(高斯消元法 & 逆矩阵)

题目大意:9种操作可以让不同的种转动90度,求最小上升的操作方式。     解题报告:这题解法众多,也很有趣。可以BFS,DFS,9重循环暴搜也没问题= =。当然,为了学习还是用高斯消元法做的。     Discuss也有人讨论了,4不是质数,求解过程中不能模4,不一定有解的问题。按照我的理解,题目既然说了有唯一解,就不用考虑这个问题了。     另外,寻找当前列的对应行时不能选绝对值最大的

SF-_- 的 ACM 博客 3040

XTU 1203 A simple problem (2014 湖南湘潭邀请赛 A题)(数学

A simple problem Accepted : 27   Submit : 296 Time Limit : 15000 MS   Memory Limit : 655360 KB Problem Description There is a simple problem. Given a number N. yo

SF-_- 的 ACM 博客 2171

素数的三种筛法比较

ACM比赛中经常能遇到

SF-_- 的 ACM 博客 2002

湖南多校对抗赛(2014.03.16) 比赛总结贴

今天湖南的一场比赛,题目是2013 ACM ICPC Southeast USA Regional Programming Contest。     我们三个水货按照正式比赛的方式,一台机打题,另外两台只看题。很有feel,最后出4题,排第四。简单总结一下。     我首先看的是最后一题,You Win!。看了一眼就知道是状态压缩DP。状态记录多少字母已经打出,以及最后一个字母的位置。略微计算

SF-_- 的 ACM 博客 1993

HDU 5446 Unknown Treasure 解题报告(Lucas定理 + 中国剩余定理)

Unknown Treasure Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 168    Accepted Submission(s): 40 Problem Description On the way to

SF-_- 的 ACM 博客 1991

Uva 417 - Word Index 解题报告(组合数)

Word Index  Encoding schemes are often used in situations requiring encryption or information storage/transmission economy. Here, we develop a simple encoding scheme that encodes particul

SF-_- 的 ACM 博客 1818

Uva 1393 - Highways 解题报告(递推)

Hackerland is a happy democratic country with m×n cities, arranged in a rectangular m by n grid and connected by m roads in the east-west direction and n roads in the north-south direction. By publi

SF-_- 的 ACM 博客 1810

Uva 10497 - Sweet Child Makes Trouble 解题报告(递推+大数)

Problem F Sweet Child Makes Trouble Input: standard input Output: standard output Time Limit: 8 seconds Children are always sweet but they can sometimes make you feel bitter. In this problem, y

SF-_- 的 ACM 博客 1786

POJ 1753 Flip Game 解题报告(高斯消元法)

题目大意:翻动一枚棋子,周围四枚棋子也要翻动,问最少翻动几次可以让棋盘上所有棋子都是黑色或者都是白色。     解题报告:这道题做法很多,可以用BFS,暴搜+位运算。这些写起来都不难,而且都可以A掉。不过最近在学习高斯消元法,所以仍然用高斯消元法去做。如果题目变成8*8,高斯消元依然可以做,暴搜就不一定了= =。     这题用高斯消元的难度在于矩阵是存在4个变元的,而且直接求解的话不能求得任

SF-_- 的 ACM 博客 1775

Timus 1807. Cartridges for Maxim 解题报告(DP+数学

#include #include #include #include #include #include using namespace std; typedef vector Data; int prime[701]; int primeNum; bool h[701]; void calPrime() { for(int i=2;i<=700;i++) if(!h[i

SF-_- 的 ACM 博客 1669
上一篇: Uva 1315 - Crazy tea party 解题报告(找规律)
下一篇: Uva 11401 - Triangle Counting 解题报告(计数)
SF-_-
博客等级 码龄14年 28粉丝 227原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值