题解 | #一封奇怪的信#

一封奇怪的信

http://www.nowcoder.com/practice/d7764905e41a413c98900e22a9cc4ec3

//用一点写一点,不够,赋值100并换行

#include<iostream>
#include<stdio.h>
#include<vector>
#include<map>
using namespace std;

int main(void)
{
    map<char,int> mp;
    
    for(char c = 'a';c<='z';c++)
        cin>>mp[c];
    
    string str;
    cin>>str;
    
    int wid=100;
    int row = 1;
    
    for(char c:str)
    {
        int cost = mp[c];
        
        if(wid <  cost)
        {
            row++;
            wid=100;
        }
        
         wid-=cost;
    }
    
    cout<<row<<" "<<100-wid;
    
    return 0;
}
全部评论

相关推荐

05-29 09:02
门头沟学院 Java
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务