zoukankan      html  css  js  c++  java
  • poj2033

    递推

    #include <cstdio>
    #include <cstring>
    
    char st[50005];
    int f[50005];
    
    bool ok(char a, char b)
    {
        if (a == '0')
            return false;
        int x = (a - '0') * 10 + b - '0';
        return x <= 26;
    }
    
    int main()
    {
        while (scanf("%s", st), st[0] != '0')
        {
            int len = strlen(st);
            f[0] = 1;
            f[1] = 1;
            for (int i = 2; i <= len; i++)
                if (st[i - 1] == '0')
                    f[i] = f[i - 2];
                else if (ok(st[i - 2], st[i - 1]))
                    f[i] = f[i - 1] + f[i - 2];    
                else
                    f[i] = f[i - 1];
            printf("%d\n", f[len]);
        }
        return 0;
    }
    View Code
  • 相关阅读:
    IOS
    XCode
    Android Studio
    Android Studio
    Cordova
    Delphi
    Cordova
    Delphi
    JQuery Mobile
    twitter ads_campaign management(图示)
  • 原文地址:https://www.cnblogs.com/rainydays/p/3133133.html
Copyright © 2011-2022 走看看