南华大学ACM新生赛暑假第一场题目和标程

                        南华大学ACM新生赛暑假第一场题目和标程
武汉大学第六届Eming杯程序设计竞赛初赛

A.Eming

Eming is a contest hold by WHUACM training team. The aim is to select new members of the team. 

Usually, the first problem is a very simple problem such as “a+b problem”. But this time, Xioumu is tired of this kind of problem, he decide to solve “a and b problem”.

Give you the result of a + b and a^2 – b^2, please output the result of a and b.

Input

There are several test cases. For each case there are two double numbers indicating a+b and a^2-b^2. You may assume that a+b will not be zero.

Output

For each case please output the result of a and b in one line, rounded to 2 decimal places.

Sample Input

3 -3

Sample Output

1.00 2.00


B.ArithmetiProgression

“In mathematics, an arithmetic progression (AP) or arithmetic sequence is a sequence of numbers such that the difference between the consecutive terms is constant. For instance, the sequence 5, 7, 9, 11, 13, … is an arithmetic progression with common difference of 2.”

Wikipedia

This is a quite simple problem, give you the sequence, you are supposed to find the length of the longest consecutive subsequence which is an arithmetic progression.

Input

There are several test cases. For each case there are two lines. The first line contains an integer number N (1 <= N <= 100000) indicating the number of the sequence. The following line describes the N integer numbers indicating the sequence, each number will fit in a 32bit signed integer.

Output

For each case, please output the answer in one line.

Sample Input

6

1 4 7 9 11 14

Sample Output

3

C.An Easy Puz

Wddpdh find an interesting mini-game in the BBS of WHU, called “An easy PUZ”. It’s a 6 * 6 chess board and each cell has a number in the range of 0 and 3(it can be 0, 1, 2 or 3). Each time you can choose a number A(i, j) in i-th row and j-th column, then the number A(i, j) and the numbers around it (A(i-1, j), A(i+1, j),A(i, j-1),A(i, j+1), sometimes there may just be 2 or 3 numbers.) will minus 1 (3 to 2, 2 to 1, 1 to 0, 0 to 3). You can do it finite times. The goal is to make all numbers become 0. Wddpdh now come up with an extended problem about it. He will give you a number N (3 <= N <= 6) indicate the size of the board. You should tell him the minimum steps to reach the goal.

Input

The input consists of multiple test cases. For each test case, it contains a positive integer N(3 <= n <= 6). N lines follow, each line contains N columns indicating the each number in the chess board.

Output

For each test case, output minimum steps to reach the goal. If you can’t reach the goal, output -1 instead.

Sample Input

3

1 1 0

1 0 1

0 1 1

3

2 3 1

2 2 1

0 1 0

Sample Output

2

3

D.Brackets 

This year MK is 5 years old. So he decides to learn some arithmetic. But he was confused by how to write the brackets. He has already known that the brackets should match when writing them correctly. Such as “()(())” is correct but “())(” is not.

The problem is that, if there are N pairs of brackets, how many ways that MK can write them correctly?           

Input 

   There are several test cases. Each case contains a number N (1 <= N <= 1000) indicating the pairs of brackets.

Output 

For each case, please output the answer mod 1,000,000,007.

Sample Input 

5

7

Sample Output 

42

429

E.Function

Define a function f(n)=(f(n-1)+1)/f(n-2). You already got f(1) and f(2). Now, give you a number m, please find the value of f(m).

Input

There are several test cases. Each case contains three integers indicating f(1), f(2) and m ( 1 <= f(1), f(2), m <= 1000,000,000).

Output

For each case, please output the value of f(m), rounded to 6 decimal places.

Sample Input

1 1 3

Sample Output

2000000

F.Triangle

It is a simple task, for N points on the 2D plane, you are supposed to find whether there are three points which could form a isosceles triangle.

Input

There are several test cases. For each case, the first line is an integer N (3 <= N <= 500) indicating the number of points. N lines follow, each line contains two doubles(not exceed 1000.0), indicating the coordinates of the points.

Output

For each case, if there exists a solution which could form a isosceles triangle, output “YES”, else output “NO”.

Sample Input

3

0 0

1 1

-1 1

3

0 0

1 1

5 10

Sample Output

YES
NO


一下是oj上的源码:

A:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

int main() {
    //freopen("Eming.out", "w", stdout);
    double A, B, C;
    while(scanf("%lf%lf", &A, &B) == 2) {
        C = B / A;
        printf("%.2lf %.2lf\n", (A + C) * 0.5, (A - C) * 0.5);
    }
    return 0;
}


B:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

const int maxn = 100000 + 5;
int seq[maxn], n;

int main() {
    //freopen("ap.out", "w", stdout);
    while(scanf("%d", &n) == 1) {
        for(int i = 0; i < n; i++) {
            scanf("%d", seq + i);
        }
        int ans = 1, s = 0, t, d;
        while(s < n - 1) {
            t = s + 1, d = seq[t] - seq[s];
            while(t < n && seq[t] - seq[t - 1] == d) t++;
            t--;
            get_max(ans, t - s + 1);
            s = t;
        }
        printf("%d\n", ans);
    }
    return 0;
}


C:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

const int maxn = 10;

int n, mat[maxn][maxn], rm[maxn][maxn], tr[maxn][maxn], ans;

int dx[] = {0, -1, 1, 0, 0};
int dy[] = {0, 0, 0, -1, 1};

bool inboard(int x, int y) {
    return 0 <= x && x < n && 0 <= y && y < n;
}

void fix(int &u, int v) {
    u += v;
    u = (u % 4 + 4) % 4;
}

void update() {
    memcpy(rm, mat, sizeof(rm));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int dir = 0; dir < 5; dir++) {
                int x = i + dx[dir];
                int y = j + dy[dir];
                if(!inboard(x, y)) continue;
                fix(rm[x][y], -tr[i][j]);
            }
        }
        if(i + 1 < n) {
            for(int j = 0; j < n; j++) {
                tr[i + 1][j] = rm[i][j];
            }
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(rm[i][j]) return;
        }
    }
    int sum = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            sum += tr[i][j];
        }
    }
    if(ans == -1 || ans > sum) ans = sum;
}
                    
void dfs(int step) {
    if(step == n) {
        update();
        return;
    }
    for(int i = 0; i < 4; i++) {
        tr[0][step] = i;
        dfs(step + 1);
    }
}

int main() {
    //freopen("Puz.out", "w", stdout);
    while(scanf("%d", &n) == 1) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                scanf("%d", &mat[i][j]);
            }
        }
        ans = -1;
        dfs(0);
        printf("%d\n", ans);
    }
    return 0;
}


D:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

const int maxn = 1000 + 5;
const int MOD = 1000000007;

typedef long long lint;

int n;
lint f[maxn];

int main() {
    //freopen("bracket.out", "w", stdout);
    f[0] = 1;
    for(int i = 1; i <= 1000; i++) {
        for(int j = 0; j < i; j++) {
            f[i] += f[j] * f[i - j - 1] % MOD;
            f[i] %= MOD;
        }
    }
    while(scanf("%d", &n) == 1) {
        printf("%I64d\n", f[n]);
    }
    return 0;
}


E:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

int m;
double a, b;
vector<double> v;

int main() {
    //freopen("fun.in", "r", stdin);
    //freopen("fun.out", "w", stdout);
    while(scanf("%lf%lf%d", &a, &b, &m) == 3) {
        v.clear();
        v.push_back(a);
        v.push_back(b);
        while(v.size() < 5) {
            int sz = v.size();
            v.push_back((v[sz - 1] + 1.0) / v[sz - 2]);
        }
        m--;
        printf("%.6lf\n", v[m % 5]);
    }
    return 0;
}


F:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

const double eps = 1e-9;

int sgn(double x) {
    return (x > eps) - (x < -eps);
}

struct point {
    double x, y;
    point(double _x = 0.0, double _y = 0.0) : x(_x), y(_y) {}
    double len() const {
        return sqrt(x * x + y * y);
    }
};

double operator * (const point &p1, const point &p2) {
    return p1.x * p2.y - p1.y * p2.x;
}

point operator - (const point &p1, const point &p2) {
    return point(p1.x - p2.x, p1.y - p2.y);
}

int n;
vector<point> v;

void out(const point &p) {
    printf("(%.2lf, %.2lf)\n", p.x, p.y);
} 

bool check() {
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                if(i == j || j == k || i == k) continue;
                point v1 = v[j] - v[i];
                point v2 = v[k] - v[i];
                if(sgn(v1.len() - v2.len()) == 0) {
                    if(sgn(v1 * v2)) {
                        out(v[i]); out(v[j]); out(v[k]);
                        printf("=============================\n");
                        return true;
                    }
                }
            }
        }
    }
    return false;
}

int main() {
    freopen("tri.in", "r", stdin);
    while(scanf("%d", &n) == 1) {
        v.clear();
        for(int i = 0; i < n; i++) {
            double x, y;
            scanf("%lf%lf", &x, &y);
            v.push_back(point(x, y));
        }
        if(check()) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <ctime>
using namespace std;
#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

int n = 500;

int main() {
    freopen("tri.in",  "w", stdout);
    srand(time(0));
    for(int testCase = 0; testCase < 10; testCase++) {
        printf("%d\n", n);
        for(int i = 0; i < n; i++) {
            double x = rand() % 100000 / 10.0;
            double y = rand() % 100000 / 10.0;
            printf("%.1lf %.1lf\n", x, y);
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

const double pi = acos(-1.0);
const double eps = 1e-9;

int sgn(double x) {
    return (x > eps) - (x < -eps);
}

int n;


struct point {
    double x, y;
    point() {}
    point(double _x, double _y) : x(_x), y(_y) {}
};

double dis(double x, double y) {
    return sqrt(x * x + y * y);
}

vector<point> pts;
vector< pair<double, double> > vec;

bool check(const vector< pair<double, double> > &vec) {
    for(int i = 0; i < vec.size(); i++) {
        double len = vec[i].first;
        double arc = vec[i].second;
        for(int j = i + 1; j < vec.size(); j++) {
            if(sgn(vec[j].first - len)) {
                i = j - 1;
                break;
            }
            else {
                if(sgn(arc - vec[j].second) == 0 || sgn(fabs(arc - vec[j].second) - pi) == 0) {
                }
                else {
                    return true;
                }
            }
        }
    }
    return false;
}

bool getAnswer() {
    for(int i = 0; i < n; i++) {
        vec.clear();
        for(int j = 0; j < n; j++) {
            if(i == j) continue;
            double arc = atan2(pts[j].y - pts[i].y, pts[j].x - pts[i].x);
            double len = dis(pts[j].y - pts[i].y, pts[j].x - pts[i].x);
            if(sgn(arc) < 0) arc += 2 * pi;
            
            vec.push_back(make_pair(len, arc));
        }
        sort(vec.begin(), vec.end());
        if(check(vec)) return true;
    }
    return false;
}
            
int main() {
    freopen("tri.out", "w", stdout);
    while(scanf("%d", &n) == 1) {
        pts.clear();
        for(int i = 0; i < n; i++) {
            double x, y;
            scanf("%lf%lf", &x, &y);
            pts.push_back(point(x, y));
        }
        printf(getAnswer() ? "YES\n": "NO\n");
    }
    return 0;
}






内容概要:本文档详细介绍了基于Cplex求解器的风光制氢合成氨系统优化研究,通过Matlab代码实现对这一复杂可再生能源系统的建模与优化分析。研究聚焦于风能、光伏等可再生能源耦合电解水制氢并进一步合成氨的综合能源系统,重点解决系统在容量配置与运行调度方面的协同优化问题。采用Cplex求解器进行高效的混合整数线性规划(MILP)求解,实现了对系统经济性、能效性、环境可持续性的多目优化,涵盖设备选型与容量设计、能量流分配、运行策略制定、制氢与合成氨工艺集成等关键技术环节。该研究为高比例可再生能源消纳、绿氢规模化生产及绿色化工转型提供了重要的理论依据与可行的技术路径。; 适合人群:具备电力系统、能源系统、运筹学或化工过系统工等相关背景,熟悉Matlab编与数学建模方法,从事新能源、氢能、综合能源系统、绿色化工等领域研究的研究生、科研人员及工技术人员。; 使用场景及目:① 学习并复现高水平学术论文中关于风光制氢合成氨系统的优化模型构建方法;② 掌握利用Cplex求解器解决复杂能源系统混合整数线性规划(MILP)问题的核心技术与实践流;③ 为自身的科研项目或工应用提供系统建模、优化算法实现与代码参考的坚实基础。; 阅读建议:学习者应结合所提供的Matlab代码与相关参考文献,深入剖析模型的物理意义、数学推导过、约束条件的设定逻辑以及目函数的设计思路,特别关注Cplex与Matlab的接口调用与数据传递机制,并建议通过调整关键参数(如可再生能源出力、设备效率、成本系数等)进行敏感性分析,以全面理解系统优化的内在机理与决策影响。
内容概要:本文系统研究了单相逆变器闭环控制下的PWM调制模型,基于Simulink平台构建完整的逆变电路仿真系统,涵盖主电路拓扑、闭环控制器设计、脉宽调制信号生成及输出滤波等关键环节。通过引入比例积分(PI)反馈控制策略,实现对输出电压幅值与波形的精确调节,有效抑制负载扰动带来的影响,提升系统的动态响应能力与稳态精度。仿真过详细展示了系统建模、参数整定及性能验证的全流,重点分析了闭环控制在改善输出正弦波质量、降低谐波畸变率方面的优势,为电力电子逆变装置的研发与优化提供了可靠的理论支撑与实践参考。; 适合人群:具备电力电子技术、自动控制原理基础知识及相关仿真经验的高校研究生、科研人员,以及从事新能源发电、不间断电源(UPS)、微电网、电动汽车等领域的工技术人员。; 使用场景及目:①掌握单相逆变器闭环控制系统的设计与建模方法;②深入理解PWM技术与反馈控制在逆变系统中的协同工作机制;③通过Simulink仿真平台完成系统搭建与参数调试,服务于课设计、毕业课题、科研项目或工业产品开发中的逆变器控制算法验证。; 阅读建议:建议结合经典控制理论与电力电子变换技术同步学习,动手复现仿真模型并尝试调整PI控制器参数、载波频率等关键变量,观察其对系统稳定性与输出性能的影响,从而深化对控制机理的理解,并为进一步研究并网逆变、多电平逆变等复杂系统打下坚实基础。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值