Codeforces Round #261 (Div. 2) B

来源:互联网 发布:oracle数据库课程 编辑:程序博客网 时间:2024/06/03 21:14

B. Pashmak and Flowers


        题意:有许多花,每朵花有一个value,选出value相差最大的两朵花,输出value的差和有多少种选法。

        思路:排序,差值就是最后一个的value减去第一个的value。然后选法种数根据乘法原理可得,注意爆int和value全部一样的情况。比赛的时候我逗比了,n*(n-1)/2写成了n/2*(n-1)。。还lock了。。


#include <iostream>    #include <stdio.h>    #include <cmath>    #include <algorithm>    #include <iomanip>    #include <cstdlib>    #include <string>    #include <memory.h>    #include <vector>    #include <queue>    #include <stack>    #include <map>  #include <set>  #include <ctype.h>    #define INF 10000000#define ll long long#define min3(a,b,c) min(a,min(b,c))#define max3(a,b,c) max(a,max(b,c))#define MAXN 100010using namespace std;  int main(){int x1,y1,x2,y2;while(cin>>x1>>y1>>x2>>y2){if(x1==x2){int t=abs(y1-y2);cout<<x1+t<<" "<<y1<<" "<<x2+t<<" "<<y2<<endl;}else if(y1==y2){int t=abs(x1-x2);cout<<x1<<" "<<y1+t<<" "<<x2<<" "<<y2+t<<endl;}else{int t1=abs(x1-x2);int t2=abs(y1-y2);if(t1!=t2){cout<<"-1"<<endl;}else{int t;if(x1>x2){t=x2;x2=x1;x1=t;  t=y2;y2=y1;y1=t;}cout<<x1<<" "<<y2<<" "<<x2<<" "<<y1<<endl;}}}return 0;}


0 0
原创粉丝点击