• FOJ有奖月赛-2015年11月 Problem B 函数求解


    Problem B 函数求解

    Accept: 171    Submit: 540
    Time Limit: 1000 mSec    Memory Limit : 32768 KB

     Problem Description

    给出n,求f(n)。

     Input

    第一行一个正整数T,表示数据组数。 接下来T行,每行一个正整数n。 T<=20,n<=2015000000。

     Output

    对于每组数据,输出一行f(n)。

     Sample Input

    2
    1
    20150001

    Sample Output

    2015
    20152014
    题目也是偶然看到的,看了一下,没一下子想懂,感觉问题出在f(f(n-2015)),应该最后是把所求的数逼近20150001;
    题解很简单:n<20150001   n+2014

          n>=20150001     20152014

    代码:

    来源:http://blog.csdn.net/qq1319479809/article/details/49851423

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<algorithm>
     4 #include<cstring>
     5 using namespace std;
     6 int main()
     7 {
     8     int t;
     9     long long n;
    10     scanf("%d",&t);
    11     while(t--)
    12     {
    13         scanf("%lld",&n);
    14         if(n<20150001)
    15         {
    16             printf("%lld
    ",n+2014);
    17         }
    18         else printf("20152014
    ");
    19     }
    20     return 0;
    21 }
  • 相关阅读:
    mybatis 版本问题
    sonar-maven-plugin问题
    spring容器&classLoader
    Mybatis知识点整理
    防重复提交的方式汇总
    秒杀系统设计整理
    MySQL事务隔离级别&锁
    disruptor解读
    springboot 2.x集成log4j2调试日志无法关闭问题
    Java并发——volatile
  • 原文地址:https://www.cnblogs.com/ISGuXing/p/7259660.html
Copyright © 2020-2023  润新知