CodeForces.5A Chat Server's Outgoing Traffic
Chat Server’s Outgoing Traffic
考察点
模拟 字符串
| Time | Mem | Len | Lang |
|---|---|---|---|
| 30 | 0 | 543 | c++ |
题意分析
给出类似一个群的即时通讯系统,会有用户的加入和离开,还会有用户发消息,每次用户发消息,都会给当前在聊天室内的用户发送该消息。消息中,每个字符(包括空格)都算一个byte,最后问总共发送了多少byte的消息。保证所有数据的合法。
记录当前聊天室内的人数,然后实时更新,并且处理字符串统计每条消息的字节数,用变量sum=+字节数*人数,最后输出即可。
代码总览
/*
Title:CodeForces.5A
Author:pengwill
Date:2016-12-14
*/
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
char str[105];
int main()
{
int num = 0,sum = 0;
while(gets(str)){
int pos,i;
int len = strlen(str);
if(str[0] == '+'){
num++;
}else if(str[0] == '-'){
num--;
}else{
for(i = 0;i<len;i++){
if(str[i] == ':'){
sum+=num*(len-1-i);
break;
}
}
}
}
printf("%d\n",sum);
return 0;
}
CodeForces.5A Chat Server's Outgoing Traffic的更多相关文章
- Codeforces Beta Round #5 A. Chat Server's Outgoing Traffic 水题
A. Chat Server's Outgoing Traffic 题目连接: http://www.codeforces.com/contest/5/problem/A Description Po ...
- Chat Server's Outgoing Traffic
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93359#problem/A (456321) http://codeforces.com ...
- [CareerCup] 8.7 Chat Server 聊天服务器
8.7 Explain how you would design a chat server. In particular, provide details about the various bac ...
- tc: Linux HTTP Outgoing Traffic Shaping (Port 80 Traffic Shaping)(转)
原文:https://www.cyberciti.biz/faq/linux-traffic-shaping-using-tc-to-control-http-traffic/ I‘ve 10Mbps ...
- Codeforces Beta Round #5 D. Follow Traffic Rules 物理
D. Follow Traffic Rules 题目连接: http://www.codeforces.com/contest/5/problem/D Description Everybody kn ...
- codeforces 469B Chat Online 解题报告
题目链接:http://codeforces.com/problemset/problem/469/B 题目意思:给出 Little Z 的上线时间段,分别是[a1, b1], [a2, b2],.. ...
- the Linux Kernel: Traffic Control, Shaping and QoS
−Table of Contents Journey to the Center of the Linux Kernel: Traffic Control, Shaping and QoS 1 Int ...
- Linux 网络流量查看 Linux ip traffic monitor
Network monitoring on Linux This post mentions some linux command line tools that can be used to mon ...
- How To Set Up an OpenVPN Server on Ubuntu 14.04
Prerequisites The only prerequisite is having a Ubuntu 14.04 Droplet established and running. You wi ...
随机推荐
- 欧陆词典PEST2词库
欧陆词典PEST2单词列表,其中大概1900+单词,可能有少数几个没有录入,但不影响使用!
- 查看linux系统版本命令汇总
Linux下如何查看版本信息, 包括位数.版本信息以及CPU内核信息.CPU具体型号等等,整个CPU信息一目了然. 1.Linux查看版本当前操作系统内核信息 命令:uname -a
- 【system.number】使用说明
对象:system.number 说明:提供一系列针对数值类型的操作 目录: 方法 返回 说明 system.number.isNumber( number ) [True | False] 检测是否 ...
- lintcode539 移动零
移动零 给一个数组 nums 写一个函数将 0 移动到数组的最后面,非零元素保持原数组的顺序 注意事项 1.必须在原数组上操作2.最小化操作数 您在真实的面试中是否遇到过这个题? Yes 样例 给出 ...
- (转)CGMA - Organic World Building in UE4: week 6
原文:丢失,这篇是艺术家博客上发现的,小道整理笔记中,临时放于效果案例目录. In this week we focused on creating the grass and flora t ...
- Java进阶——— 线程池的原理分析
前言 在了解线程池之前,其实首先出现的疑问是:为什么要使用线程池,其次是了解什么是线程池,最后是如何使用线程池,带着疑问去学习. 为什么要使用 前面多线程文章中,需要使用线程就开启一个新线程,简单方便 ...
- Hadoop第二课:Hadoop集群环境配置
一.Yum配置 1.检查Yum是否安装 rpm -qa|grep yum 2.修改yum源,我使用的是163的镜像源(http://mirrors.163.com/),根据自己的系统选择源, #进入目 ...
- VBA基础之Excel VBA 表格的操作(一)
一.Excel VBA 表格的操作1. Excel表格的指定以及表格属性的设置 Sub main() '把表格B2的值改为"VBA Range和Cells函数" Range(&qu ...
- c++反射概念-简单介绍
C++ 反射机制的简单实现 C++并不支持反射机制,只能自己实现. 如果需要实现字字符串到函数到映射,一定要使用到函数指针. 简单实现反射机制,根据字符串来构造相应到类.主要有以下几点: (1) 可以 ...
- 《软件工程实践》第五次作业-WordCount进阶需求 (结对第二次)
在文章开头给出结对同学的博客链接.本作业博客的链接.你所Fork的同名仓库的Github项目地址 本作业博客链接 github pair c 031602136魏璐炜博客 031602139徐明盛博客 ...