复习时间

来源:互联网 发布:淘宝零食店排行榜 编辑:程序博客网 时间:2024/06/07 14:24

复习时间

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8422    Accepted Submission(s): 6181


Problem Description
为了能过个好年,xhd开始复习了,于是每天晚上背着书往教室跑。xhd复习有个习惯,在复习完一门课后,他总是挑一门更简单的课进行复习,而他复习这门课的效率为两门课的难度差的平方,而复习第一门课的效率为100和这门课的难度差的平方。xhd这学期选了n门课,但是一晚上他最多只能复习m门课,请问他一晚上复习的最高效率值是多少?
 

Input
输入数据的第一行是一个数据T,表示有T组数据。
每组数据的第一行是两个整数n(1 <= n <= 40),m(1 <= m <= n)。
接着有n行,每行有一个正整数a(1 <= a <= 100),表示这门课的难度值。
 

Output
对于每组输入数据,输出一个整数,表示最高效率值。
 

Sample Input
22 2522512 589646435672922320223731
 

Sample Output
56258836
 

Author
xhd
 

Source
ACM程序设计期末考试_热身赛(感谢 xhd & 8600)
 

Recommend
lcy   |   We have carefully selected several similar problems for you:  2079 2076 2082 2077 2073 
 
#include<iostream>#include<cstdlib>#include<cstdio>#include<cmath>#include<cstring>#include<string>#include<cstdlib>#include <set>#include<algorithm>#include <limits.h>#include <ctype.h>#include <map>#include <stack>typedef long long LL;using namespace std;const int N = 105;int data[N][N];int dp[N][N];int f[35];char c[6] = {'A', 'B', 'C', 'D', 'E', 'F'};float obj[5];void fun(int n, int m){    int flag = 0;    if(n < 0){        flag = 1;        n = -n;    }    stack<char> s1;    while(n != 0){        int yushu = n % m;        if(yushu >= 10){            s1.push(c[yushu - 10]);        }else {            s1.push(yushu + '0');        }        n =  n / m;    }    if(flag){        cout << "-";    }    while(!s1.empty()){        cout << s1.top();        s1.pop();    }    cout << endl;}int gcd(int a, int b){    return b == 0 ? a : gcd(b, a % b);}int lcm(int a, int b){    return a  / gcd(a, b) * b;}int main() {    //freopen("in.txt","r",stdin);    //freopen("out.txt","w",stdout);//    int n, sum;//    while(scanf("%d %d", &n, &sum) != EOF){//        if(n == 0 && sum == 0) break;//        for(int i = 1; i <= n; i++){//            int T = 0;//            for(int j = i; j <= n; j++){//                T += j;//                if(T == sum ){//                    cout << "["<< i << "," << j <<"]"<< endl;//                    break;//                }else if(T < sum){//                    continue;//                }else {//                    break;//                }//            }//        }//        cout << endl;//    }    int T;    cin >> T;    while(T--){        int n, m;        cin >> n >> m;        vector<int> v1;        for(int i = 0; i < n; i++){            int temp;            cin >> temp;            v1.push_back(temp);        }        sort(v1.begin(), v1.end());        cout << (100 - v1[0]) * (100 - v1[0]) << endl;    }    return 0;}

0 0
原创粉丝点击