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的更多相关文章

  1. 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 ...

  2. Chat Server's Outgoing Traffic

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93359#problem/A (456321) http://codeforces.com ...

  3. [CareerCup] 8.7 Chat Server 聊天服务器

    8.7 Explain how you would design a chat server. In particular, provide details about the various bac ...

  4. 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 ...

  5. Codeforces Beta Round #5 D. Follow Traffic Rules 物理

    D. Follow Traffic Rules 题目连接: http://www.codeforces.com/contest/5/problem/D Description Everybody kn ...

  6. codeforces 469B Chat Online 解题报告

    题目链接:http://codeforces.com/problemset/problem/469/B 题目意思:给出 Little Z 的上线时间段,分别是[a1, b1], [a2, b2],.. ...

  7. 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 ...

  8. Linux 网络流量查看 Linux ip traffic monitor

    Network monitoring on Linux This post mentions some linux command line tools that can be used to mon ...

  9. 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 ...

随机推荐

  1. Date 工具类(包含常用的一些时间方法)

    package com.fh.util; import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseE ...

  2. cf#514B. Forgery(暴力)

    B. Forgerytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputsta ...

  3. Python常见的脚本汇总

    1.冒泡排序 lis = [56,12,1,8,354,10,100,34,56,7,23,456,234,-58] def sortport(): for i in range(len(lis)-1 ...

  4. Selenium 入门到精通系列:四

    Selenium 入门到精通系列 PS:鼠标右键.鼠标悬停.键盘操作方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019 ...

  5. GIt学习第一天之安装和版本库创建

    搬运自 ‘廖雪峰的官方网站’ 1.git安装 官网下载地址:https://git-scm.com/download/win   百度网盘下载地址:https://pan.baidu.com/s/1k ...

  6. Linux命令应用大词典-第12章 程序编译

    12.1 gcc:GNU项目的C和C++编译器 12.2 gdberver:为GNU调试的远程服务器 12.3 cmake:跨平台的Makefile生成工具 12.4 indent:更改通过插入或删除 ...

  7. 微服务框架Dubbo与Springcloud的区别

    微服务框架Dubbo与Springcloud的区别 微服务主要的优势如下: 1.降低复杂度 将原来偶合在一起的复杂业务拆分为单个服务,规避了原本复杂度无止境的积累.每一个微服务专注于单一功能,并通过定 ...

  8. 【outPut_Class 输出类】使用说明

    对象:outPut 说明:定义输出结果类的相关操作.此对象的核心是[JSON]类,所以它继承了[JSON]类的所有方法 重要: 输出结果样式为XML时,自带根节点"root".输出 ...

  9. Python全栈 进阶(进阶内容都在这了)

    原文地址 https://yq.aliyun.com/articles/632754?spm=a2c4e.11155435.0.0.23eb3312feB6dG ................... ...

  10. spark集群安装部署

    通过Ambari(HDP)或者Cloudera Management (CDH)等集群管理服务安装和部署在此不多介绍,只需要在界面直接操作和配置即可,本文主要通过原生安装,熟悉安装配置流程. 1.选取 ...