Algorithm


Problem Name: beecrowd | 1114

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1114

beecrowd | 1114

Fixed Password

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that keep reading a password until it is valid. For each wrong password read, write the message "Senha inválida". When the password is typed correctly print the message "Acesso Permitido" and finished the program. The correct password is the number 2002.

Input

The input file contains several tests cases. Each test case contains only an integer number.

Output

For each number read print a message corresponding to the description of the problem.

 
Input Sample Output Sample

2200
1020
2022
2002

Senha Invalida
Senha Invalida
Senha Invalida
Acesso Permitido

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include<bits/stdc++.h>

using namespace std;

int main(){
    while(1){
        int password;
        cin >> password;
        if (password == 2002){
            cout << "Acesso Permitido" << endl;
            break;
        }
        else{
            cout << "Senha Invalida" << endl;
        }
    }
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
2200 1020 2022 2002

Output

x
+
cmd
Senha Invalida Senha Invalida Senha Invalida Acesso Permitido

#2 Code Example with Java Programming

Code - Java Programming


import java.io.IOException;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) throws IOException{
        Scanner input = new Scanner(System.in);
        while(true){
            int password = input.nextInt();
            if (password == 2002){
                System.out.println("Acesso Permitido");
                break;
            }
            else{
                System.out.println("Senha Invalida");
            }
        }
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
2200 1020 2022 2002

Output

x
+
cmd
Senha Invalida Senha Invalida Senha Invalida Acesso Permitido

#3 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

while(true){
    var password = parseInt(lines.shift());
    if (password == 2002){
        console.log("Acesso Permitido");
        break;
    }
    else{
        console.log("Senha Invalida");
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
2200 1020 2022 2002

Output

x
+
cmd
Senha Invalida Senha Invalida Senha Invalida Acesso Permitido

#4 Code Example with Python Programming

Code - Python Programming


while(True):
    password = int(input())
    if (password == 2002):
        print("Acesso Permitido")
        break
    else:
        print("Senha Invalida")
Copy The Code & Try With Live Editor

Input

x
+
cmd
2200 1020 2022 2002

Output

x
+
cmd
Senha Invalida Senha Invalida Senha Invalida Acesso Permitido
Advertisements

Demonstration


Previous
#1113 Beecrowd Online Judge Solution 1113 Ascending and Descending Solution in C++, Java, Js and Python
Next
#1115 Beecrowd Online Judge Solution 1115 Quadrant Solution in C++, Java, Js and Python