-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5b.cpp
More file actions
49 lines (44 loc) · 861 Bytes
/
5b.cpp
File metadata and controls
49 lines (44 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;
set <int> IDS;
int main(){
string datos;
int ID_great=0;
while(getline(cin,datos)){
int ID=0;
float fila_first=0;
float fila_end=127;
float fila=0;
float column_first=0;
float column_end=7;
float column=0;
float i=0;
while(i<11 and fila_first<fila_end){
if(datos[i]=='F'){
fila_end=(fila_end+fila_first)/2;
fila=floor(fila_end);
}
if(datos[i]=='B'){
fila_first=(fila_end+fila_first)/2;
fila=ceil(fila_first);
}
if(datos[i]=='R'){
column_first=(column_end+column_first)/2;
column=ceil(column_first);
}
if(datos[i]=='L'){
column_end=(column_end+column_first)/2;
column=floor(column_end);
}
i++;
}
ID=fila*8+column;
IDS.insert(ID);
}
for(auto x: IDS){
cout<<x<<endl;
}
}