forked from hughbzhang/Competitive_Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cipher.cpp
48 lines (44 loc) · 1.23 KB
/
cipher.cpp
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
#include <cstdio>
#include <iostream>
using namespace std;
int arr[2000];
int main(){
freopen("cipher.txt","r",stdin);
int cnt = 0, num;
while(cin >> num){
arr[cnt] = num;
cnt++;
}
for(int x = 0;x<cnt;x++){
// cout << arr[x] << endl;
}
//for(int a = 97;a<123;a++){
int a = 103;
int b = 111;
int c = 100;
//for(int b = 97;b<123;b++){
//for(int c = 97;c<123;c++){
bool flag = true;
string pos = "";
int e = 0;
int total = 0;
for(int x = 0;x<cnt;x++){
int out;
if(x%3==0) out = (a^arr[x]);
else if(x%3==1) out = (b^arr[x]);
else out = (c^arr[x]);
pos.push_back(char(out));
if(out==69||out==101) e++;
if(out<32){
flag = false;
break;
}
total+=out;
}
if(flag&&e>cnt/20){ cout << pos << endl;
cout << a << " " << b << " " << c << endl;}
//}
cout << total << endl;
//}
//}
}