zoukankan      html  css  js  c++  java
  • [解题报告]10696 f91

    Problem A - f91

    Time Limit: 1 second

    Background

    McCarthy is a famous theorician of computer science. In his work, he defined a recursive function, called f91, that takes as input a positive integer N and returns a positive integer defined as follows:

    • If N ≤ 100, then f91(N) = f91(f91(N+11));
    • If N ≥ 101, then f91(N) = N-10.

    The Problem

    Write a program, that computes McCarthy's f91.

    The Input

    The input tests will consist of a series of positive integers, each integer is at most 1,000,000. There will be at most 250,000 test cases. Each number is on a line on its own. The end of the input is reached when the number 0 is met. The number 0 shall not be considered as part of the test set.

    Output

    The program shall output each result on a line by its own, following the format given in the sample output.

    Sample input

    500
    91
    0
    

    Sample output

    f91(500) = 490
    f91(91) = 91




    运气真好,赶工的时候碰到好多水题。。。

    #include<stdio.h>
    int main()
    {
      int N;
      while(scanf("%d",&N)!=EOF&&N)
      {
        if(N<=100)
          printf("f91(%d)=91\n",N);
        else
          printf("f91(%d)=%d\n",N,N-10);
      }
      return 0;
    }
  • 相关阅读:
    读取列表下标
    字典dict详解
    使用mysql的长连接
    oauth授权协议的原理
    安装性能测试工具:sysbench和使用apache的ab
    发送邮件出现问题
    获取用户的真实ip
    清理代码的阅读笔记
    开发中三个经典的原则
    要干大事就不能把面子看得太重
  • 原文地址:https://www.cnblogs.com/TheLaughingMan/p/2932130.html
Copyright © 2011-2022 走看看