首页 > 其他 > 详细

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

时间:2014-10-02 10:11:12      阅读:232      评论:0      收藏:0      [点我收藏+]

链接:here~~~

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

bubuko.com,布布扣
#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

 

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

原文:http://www.cnblogs.com/zsj-93/p/4003859.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!