fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int sum(string s){
  4. return ((s[0]>>1)<<1)+1 + (s[1]>>1)<<1;
  5. }
  6. void printFlag(int a, int b, int c, string s){
  7. string k="";
  8. k += to_string(char(a));
  9. k.push_back(char(b));
  10. k += to_string(char(c));
  11. string A="";
  12. string B="";
  13. int p1[] = {29,40,-12,-21,19,-19,1,33,21,40,-12,49,29,-4,-8,-8};
  14. int p2[] = {130,103,90,152,123,121,107,155,131,83,86,135,130,120,132,94};
  15. for(int n:p1){
  16. A.push_back(n+sum(s));
  17. }
  18. for(int n:p1){
  19. B.push_back(n-s[0]);
  20. }
  21. string ans = k + "{" + A + "__" + B + "}";
  22. cout<<ans<<endl;
  23.  
  24. }
  25. int binTodec(int n){
  26. int a = 0;
  27. for(int p=0; n!=0; p++){
  28. if(n%10) a = a + pow(2, p);
  29. n = n/10;
  30. }
  31. return a;
  32. }
  33.  
  34. bool check(int a, int b, int c, string s){
  35. if(a!= sum(s)) return 0;
  36. return (a+b+c == 218 && c==70);
  37. }
  38. void func(int n1, int n2, int n3, string key){
  39. char a = binTodec(n1);
  40. char b = binTodec(n2);
  41. char c = binTodec(n3);
  42. if(check(a, b, c, key)) {
  43.  
  44. cout<<"Is the flag really correcnt though?"<<endl;
  45. printFlag(a, b, c, key);
  46. return;
  47. // cout<<""
  48. }
  49. else{
  50. cout<<"lol";
  51. }
  52. }
  53.  
  54.  
  55. int main(){
  56. int n1;
  57. int n2;
  58. int n3;
  59. string s;
  60. printf("Enter binary number: \n");
  61. cin>>n1;
  62. printf("Enter binary number: \n");
  63. cin>>n2;
  64. printf("Enter binary number: \n");
  65. cin>>n3;
  66. printf("Enter string ! To get Money $: \n");
  67. cin>>s;
  68.  
  69. func(n1, n2, n3, s);
  70.  
  71.  
  72.  
  73. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
Enter binary number: 
Enter binary number: 
Enter binary number: 
Enter string ! To get Money $: 
lol