• 2010有道难题练习赛


    http://poj.youdao.com/nanti/

    题目编号 标题 通过率 通过人数 提交次数
    A A + B 12% 1608 9483
    B Power 7% 406 4880
    C Sibonacci 4% 80 2452

    描述
    计算a加b。
    输入
    一行,用空格分开的两个整数a和b。
    其中0≤a, b≤10000。
    输出
    一个整数,为a加b的和。
    样例输入
    1 2
    样例输出
    3
    #include <stdio.h>

    int main()
    {
        
    long a,b;
        scanf(
    "%d%d",&a,&b);
        printf(
    "%d",a+b);
        
    return 0;
    }


    B:Power

    时间限制:
    1000ms
    内存限制:
    65536kB
    描述
    计算a的b次方对9907取模的值。
    输入
    第一行有一个正整数T,表示有T组测试数据。
    接下来T行,每行是一组测试数据,包含两个整数a和b。
    其中T<=10000, 0 <=a,b < 2^31。
    输出
    有T行,依次输出每组数据的结果。
    样例输入
    3
    1 2
    2 3
    3 4
    样例输出
    1
    8
    81

    代码
    #include <stdio.h>

    long mod(long a, long b, long c)
    {
        
    if(a>=c)
            
    return mod(a%c,b,c);
        
    if(a==0)
            
    return 0;
        
    if(a==1)
            
    return 1%c;
        
    if(b==0)
            
    return 1%c;
        
    if(b==1)
            
    return a%c;
        
    long b1=b/2;
        
    long x = mod(a, b1, c);
        
    if(b%2)
        {
            
    return (x*x*(a%c))%c;
        }
        
    else
            
    return (x*x)%c;
    }

    int main()
    {
        
    long T, a,b;
        scanf(
    "%d",&T);
        
    for(long i=0; i<T; i++)
        {
            scanf(
    "%d%d",&a,&b);
            printf(
    "%d\n",mod(a,b,9907));
        }
        
    return 0;
    }

    C:Sibonacci

    时间限制:
    1000ms
    内存限制:
    65536kB
    描述
    菲波那切数列可以用下列的式子表示:
    f(1)=1
    f(2)=1
    f(n)=f(n-1)+f(n-2) (n>=3)

    现在我们根据这个规则定义另一种数列 命名为"辛波那切数列", 它是这样定义的:
    s(x)=0 (x<0)
    s(x)=1 (0<=x<1)
    s(x)=s(x-1)+s(x-3.14) (x>=1)

    现在需要计算出s(x) MOD 1000000007的值。
    输入
    第一行有一个正整数T表示有T组测试数据。
    接下来T行,每行包含一个数x。
    其中 T<=10000, -1000.0<=x<=1000.0
    输出
    有T行,依次输出每组数据的结果。
    样例输入
    3
    -1
    0.667
    3.15
    样例输出
    0
    1
    2

    代码
    //http://topic.csdn.net/u/20080426/15/1f5a0104-9f7c-49b3-80da-391596186259.html
    #include<stdio.h>
    #define MAXN 100000
    int a[MAXN];

    int main()
    {
      
    int t,i,k;
      
    double x;
      
    for(i=0;i<314;i++)
      {
        a[i]
    =1;
      }
      
    for(i=314;i<MAXN;i++)
      {
          a[i]
    =a[i-100]+a[i-314];
          a[i]
    %=1000000007;
      }
      scanf(
    "%d",&t);
      
    while(t--)
      {
          scanf(
    "%lf",&x);
          
    if(x<0)
          {
              printf(
    "0\n");
              
    continue;
          }
          x
    *=100;
          k
    =(int)(x+0.000001);
          printf(
    "%d\n",a[k]);
      }
      
    return 0;
    }


    最近的提交

    题目 结果 内存 耗时 编程语言 提交时间
    C: Sibonacci Accepted 720kB 10ms G++ 2010-05-24 22:53:31
    B: Power Accepted 276kB 10ms G++ 2010-05-24 22:40:27
    A: A + B Accepted 276kB 0ms G++ 2010-05-24 22:19:20
     

  • 相关阅读:
    mongodb3.6 query plan机制变更导致慢查询问题排查
    zoj 3822 概率期望dp入门
    poj 4513 吉哥系列故事――完美队形II 最长回文子串
    poj 3974 Palindrome O(n)回文子串(Manacher)算法
    hdu 4405 Aeroplane chess 概率dp入门题
    hdu 5001 walk 概率dp入门题
    hdu 3586 Information Disturbing 树形dp+二分
    hdu 2296 Ring AC自动机+DP
    poj 3691 DNA repair AC自动机+DP
    hdu 1520 Anniversary party 树形dp水题
  • 原文地址:https://www.cnblogs.com/cutepig/p/1743125.html
Copyright © 2020-2023  润新知