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
- Codeforces Round #261 (Div. 2) B
- Codeforces Round #261 (Div. 2)B. Pashmak and Flowers
- Codeforces Round #261 (Div. 2) B.Pashmak and Flowers
- Codeforces Round #261 (Div. 2) B. Pashmak and Flowers【水】
- Codeforces Round #261 (Div. 2) A,B,C,D,E
- Codeforces Round #261 (Div. 2) B. Pashmak and Flowers
- Codeforces Round #261 (Div. 2)B. Pashmak and Flowers
- Codeforces Round #261 (Div. 2) B. Pashmak and Flowers 水题
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #134 (Div. 2)B. Airport
- Codeforces Round #170 (Div. 2) problem B
- Codeforces Round #173 (Div. 2) Problem B
- Codeforces Round #181 (Div. 2) B. Coach
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #171 (Div. 2) B
- Codeforces Round #169 (Div. 2) B题
- Codeforces Round #188 (Div. 2) B题
- Codeforces Round #192 (Div. 2) B
- Centos成功安装mysql-5.5.37
- 最简单git服务器配置-SSH连接方式
- Java虚拟机工作原理详解
- Qt——中心窗口setCentralWidget
- OC字符串NSString类的模拟封装-init方法
- Codeforces Round #261 (Div. 2) B
- ZOJ1463:Brackets Sequence(区间DP)
- 以另一种位图的思想来解决一道OJ题目
- michael kors outlet ozezbt lrq senk
- JAVA解析纯真IP地址库
- python中怎么import自己写的模块
- 三猿开泰,走进普通、文艺、2B程序猿的逗比世界
- 猜数字游戏(rand()、srand()、time()以及return的用法)
- poj 1942 Paths on a Grid