1006星际密码

题目链接

版本T

#include 
int main(){
    int n;
  
    int password[100001];
    password[1] = 1;
    password[2] = 2;
    for (int i = 3; i <= 10000; i++)
        password[i] = ( password[i - 1] + password[i - 2] ) % 10000;
  
    int number[100];
    int i;
    while (std::cin >> n && n >= 1 && n <= 100) {
  
        for (i = 0; i < n; i++)
            std::cin >> number[i];
  
        for (i = 0; i < n; i++) {
  
            if (password[number[i]] / 10 == 0)
                std::cout << "000";
            else if (password[number[i]] / 100 == 0)
                std::cout << "00";
            else if (password[number[i]] / 1000 == 0)
                std::cout << "0";
  
            std::cout << password[number[i]];
        }
  
        std::cout << std::endl;
    }
  
    return 0;
}

你可能感兴趣的:(PAT乙级练习题)