码迷,mamicode.com
首页 > 其他好文 > 详细

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

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

标签:style   blog   http   color   io   os   ar   for   sp   

链接: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 (贪心)

标签:style   blog   http   color   io   os   ar   for   sp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!