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 ...
随机推荐
- InnoDB锁冲突案例演示
Preface As we know,InnoDB is index organized table.InnoDB engine supports row-level lock bas ...
- centos7下搭建django
安装环境:centos7.4 1 安装nginx yum install nginx 注:尝试过在本地和腾讯云上安装,使用同一条命令:在本地安装提示没有可用安装包,云上安装正常 启动nginx,并启用 ...
- Siki_Unity_1-9_Unity2D游戏开发_Roguelike拾荒者
Unity 1-9 Unity2D游戏开发 Roguelike拾荒者 任务1:游戏介绍 Food:相当于血量:每走一步下降1,吃东西可以回复(果子10药水20),被怪物攻击会减少中间的障碍物可以打破, ...
- python 终极篇 ---django 认证
Django自带的用户认证 我们在开发一个网站的时候,无可避免的需要设计实现网站的用户系统.此时我们需要实现包括用户注册.用户登录.用户认证.注销.修改密码等功能,这还真是个麻烦的事情呢. Djang ...
- hive使用spark引擎的几种情况
使用spark引擎查询hive有以下几种方式:1>使用spark-sql(spark sql cli)2>使用spark-thrift提交查询sql3>使用hive on spark ...
- Python实用技巧
1.改变工作目录 import os os.chdir('C:/Users/Mr.Zhao') 2.搜索制定目录下的文件 1 import glob 2 glob.glob('C:/User/Mr.Z ...
- Java中I/O流之轮换流
Java 中的轮换流: 非常有用,可以把一个字节流转换成字符流. inputStreamReader, outputStreamReader Demo_1: import java.io.*; cla ...
- s3c2440调试nandflash裸机程序遇到的问题
图挂了可以去 https://github.com/tanghammer/mini2440_peripherals/blob/master/nand/debug_nand.md 按照前面sdram的代 ...
- BAT批处理(四)
网络命令 net use \\ip\ipc$ " " /user:" " 建立IPC空链接 net use \\ip\ipc$ "密码" / ...
- ES6之 =>箭头函数
原文,请点此链接http://www.cnblogs.com/allenxieyusheng/p/5784728.html 1. 第一个函数 ()=>1 解析:其实这是一个匿名函数直接执行 (f ...