zoukankan      html  css  js  c++  java
  • 数的计数(Noip2001)

     1 #include<iostream>
     2 #include<cstdio>
     3 using namespace std;
     4 int main()
     5 {
     6     freopen("nums.in","r",stdin);
     7     freopen("nums.out","w",stdout);
     8     int a[1001],n;
     9     cin>>n;
    10     a[1]=1;
    11     for(int s=2;s<=n;s++)
    12     {
    13         a[s]=0;
    14         for(int i=1;i<=s/2;i++)
    15         {
    16             a[s]+=a[i];
    17         }
    18         a[s]++;
    19     }
    20     cout<<a[n];
    21     return 0;
    22 }
    w】数的计数(Noip2001)
    w【问题描述】
    w我们要求找出具有下列性质数的个数(包括输入的自然数n)。先输入一个自然数n(n≤1000),然后对此自然数按照如下方法进行处理:
    w不作任何处理;
    w在它的左边加上一个自然数,但该自然数不能超过原数的一半;
    w加上数后,继续按此规则进行处理,直到不能再加自然数为止。
    w输入:自然数n(n≤1000)
    w输出:满足条件的数
    w【输入样例】
    w       6     满足条件的数为  6   (此部分不必输出)
    w                          16
    w                          26
    w                         126
    w                         36
    w                         136
    w【输出样例】
    w       6
     
  • 相关阅读:
    Flask 随记
    Notes on Sublime and Cmder
    Algorithms: Design and Analysis Note
    LeetCode 215 : Kth Largest Element in an Array
    LeetCode 229 : Majority Element II
    LeetCode 169 : Majority Element
    LeetCode 2:Add Two Numbers
    LeetCode 1:Two Sum
    Process and Kernel
    安装好scala后出现“找不到或无法加载主类”的问题
  • 原文地址:https://www.cnblogs.com/lyqlyq/p/6598657.html
Copyright © 2011-2022 走看看