当前位置:网站首页>(lightoj - 1410) consistent verbs (thinking)
(lightoj - 1410) consistent verbs (thinking)
2022-07-06 07:38:00 【AC__ dream】
Topic link :Consistent Verdicts | LightOJ
The question : There are... On a plane n personal , give n Personal position , Everyone has a grab , And everyone will shoot a bullet , this n Individuals can hear gunshots at the same distance , Give at random n A number represents the gunshot that everyone can hear except himself , this n A number may or may not be legal , Now ask the total number of legal schemes ?
This question is actually a thinking question , Direct thinking is not easy to solve problems , We just want to , If the distance everyone hears is limited , Then the answer is fixed , But there may be multiple distances corresponding to the same situation , For example, when the distance between everyone is greater than 1000 when , So if everyone hears the distance is 0~1000, Then everyone hears the gunshot 0, Therefore, it is not difficult for us to think , When the distance between all people increases in order ( After removing the repeated distance ) Arranged as a[1],a[2],……, Then the distance to hear the sound is 0~a[1]-1,a[1]~a[2]-1,…… Each corresponds to a legal scheme , in other words The number of different distances between people plus 1 Is the answer , This can be well understood , The idea is still quite wonderful
Here is the code :
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
using namespace std;
#define int long long
const int N=703;
vector<int>alls;
int x[N],y[N];
signed main()
{
int T;
cin>>T;
for(int _=1;_<=T;_++)
{
int n;
scanf("%lld",&n);
for(int i=1;i<=n;i++)
scanf("%lld%lld",&x[i],&y[i]);
alls.clear();
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
alls.push_back((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
sort(alls.begin(),alls.end());
alls.erase(unique(alls.begin(),alls.end()),alls.end());
printf("Case %lld: %lld\n",_,alls.size()+1);
}
return 0;
}
边栏推荐
- Typescript interface and the use of generics
- [online problem processing] how to kill the corresponding process when the MySQL table deadlock is caused by the code
- edge浏览器 路径获得
- Typescript void base type
- Set picture annotation in markdown
- Generator Foundation
- [MySQL learning notes 29] trigger
- 杰理之如若需要大包发送,需要手机端修改 MTU【篇】
- C # display the list control, select the file to obtain the file path and filter the file extension, and RichTextBox displays the data
- datax自检报错 /datax/plugin/reader/._drdsreader/plugin.json]不存在
猜你喜欢
Comparison of usage scenarios and implementations of extensions, equal, and like in TS type Gymnastics
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
[online problem processing] how to kill the corresponding process when the MySQL table deadlock is caused by the code
Relevant introduction of clip image
Three no resumes in the software testing industry. What does the enterprise use to recruit you? Shichendahai's resume
Ble of Jerry [chapter]
TypeScript接口与泛型的使用
Go learning -- implementing generics based on reflection and empty interfaces
word中如何删除某符号前面或后面所有的文字
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
随机推荐
HTTP cache, forced cache, negotiated cache
Is the super browser a fingerprint browser? How to choose a good super browser?
Emo diary 1
word中把帶有某個符號的行全部選中,更改為標題
word中把带有某个符号的行全部选中,更改为标题
[MySQL learning notes 32] mvcc
Typescript function definition
Games101 Lesson 7 shading 1 Notes
TS 类型体操 之 循环中的键值判断,as 关键字使用
杰理之如若需要大包发送,需要手机端修改 MTU【篇】
C intercept string
How can word delete English only and keep Chinese or delete Chinese and keep English
In the era of digital economy, how to ensure security?
Database addition, deletion, modification and query
杰理之BLE【篇】
The way to learn go (II) basic types, variables and constants
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
qt颜色与字符串、uint相互转换
C语言 简单易懂的高精度加法
P3047 [USACO12FEB]Nearby Cows G(树形dp)