zoukankan      html  css  js  c++  java
  • 220 DIV2 B. Inna and Nine

    220 DIV2 B. Inna and Nine

    input

    369727

    output

    2

    input

    123456789987654321

    output

    1

    题意:比如例子1:369727-->99727-->9997 , 369727-->99727-->9979

    14545181例子2:14545181-->1945181-->194519-->19919,

             14545181-->1945181-->199181-->19991

    但是:14545181-->149591这是错的

    注意:使用__int64

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <cmath>
     4 #include <cstdlib>
     5 #include <iostream>
     6 #define M 100005
     7 char s[M];
     8 
     9 int main()
    10 {
    11     //freopen("in.txt","r",stdin);
    12     while(~scanf("%s",s))
    13     {
    14         int i,n;
    15         n=strlen(s);
    16         __int64 ans=1;
    17         for(i=0;i<n;i++)
    18         {
    19             if(s[i]-'0'+s[i+1]-'0'==9 && i+1<n)
    20             {
    21                 __int64 c=1;
    22                 while(s[i]-'0'+s[i+1]-'0'==9)
    23                 {
    24                     c++;
    25                     i++;
    26                 }
    27                 if(c%2==0)
    28                 ans*=1;
    29                 else
    30                 ans*=(c/2+1);
    31             }
    32         }
    33         printf("%I64d
    ",ans);
    34     }
    35     return 0;
    36 }
    View Code
  • 相关阅读:
    C语言博客作业03--函数
    C博客作业02--循环结构
    C博客作业01--分支、顺序结构
    我的第一篇博客
    迭代购物车Dao&&GUI
    Java购物车大作业01
    DS-查找
    DS-图
    DS--树
    DS博客作业02--栈和队列
  • 原文地址:https://www.cnblogs.com/xuesen1995/p/4129264.html
Copyright © 2011-2022 走看看