zoukankan      html  css  js  c++  java
  • 数的计算

    问题 A: 数的计算

    时间限制: 5 Sec  内存限制: 125 MB
    提交: 99  解决: 35
    [提交] [状态] [讨论版] [命题人:外部导入]

    题目描述

    我们要求找出具有下列性质数的个数(包含输入的自然数n):

    输入一个自然数n(n <= 1000),并定义自然数M的初始值为n,然后按照如下规则进行处理: 
        1. 不作任何处理; 
        2. 若M >= 2,则在自然数n的左侧追加一个自然数n1,n1可取不大于M/2的任何数; 
        3. 追加数后,令M = n1,回到第1步。 

    输入

    每个测试文件只包含一组测试数据,每组输入一个自然数n(n<=1000)。

    输出

    对于每组输入数据,输出满足条件的数的个数。

    样例输入 Copy

    6
    

    样例输出 Copy

    6
    

    提示

    样例输入中,满足条件的数为: 
        6,16,26,126,36,136 
    因此输出为6
     
     
     
     
     1 #include <iostream>
     2 #include <string>
     3 using namespace std;
     4 int main(){
     5     string s1;
     6     getline(cin, s1);
     7     int sum = 1;
     8     char c = s1[0];
     9     for(string::iterator it = s1.begin(); it != s1.end(); it++){
    10         if(*it != c){
    11             c = *it;
    12             sum++;
    13         }
    14     }
    15     cout << s1.size() / sum << endl;
    16 }
     
     
     
     
  • 相关阅读:
    去哪儿网门票数据爬虫更新
    每周进度总结12
    每日进度总结20
    每日进度总结19
    每日进度总结18
    每日进度总结17
    每日进度总结16
    每日进度总结15
    每日进度总结14
    每周进度总结11
  • 原文地址:https://www.cnblogs.com/AGoodDay/p/10564779.html
Copyright © 2011-2022 走看看