Codeforces Round #227 (Div. 2) / 387C George and Number (贪心)

链接:here~~~

分割最多的数,使得分割的数连接在一起,得到原来的数,(分割的数大的放前面,两个数合并 比较此数大于后面的数,否则合并成一个数,不能分割,0不能单独存在)

#include<iostream>
using namespace std;

int main()
{
    string s;

    int i , j , ans = 0;

    cin >> s;

    for( i = 0; s[i] ;i = j)
    {
        for(j = i + 1 ; s[j] == '0';j ++);

        if(j - i > i || j - i == i && s[0] < s[i]) ans = 1;
        else ans ++;
    }

    cout << ans << endl;
}
View Code

 

posted @ 2014-10-02 09:37  风儿-zsj  阅读(128)  评论(0编辑  收藏  举报