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 ...
随机推荐
- 「日常训练」Card Game Cheater(HDU-1528)
题意与分析 题意是这样的:有\(n\)张牌,然后第一行是Adam的牌,第二行是Eve的牌:每两个字符代表一张牌,第一个字符表示牌的点数,第二个表示牌的花色.Adam和Eve每次从自己的牌中选出一张牌进 ...
- 180619-Yaml文件语法及读写小结
Yaml文件小结 Yaml文件有自己独立的语法,常用作配置文件使用,相比较于xml和json而言,减少很多不必要的标签或者括号,阅读也更加清晰简单:本篇主要介绍下YAML文件的基本语法,以及如何在Ja ...
- DirectX11与DirectX12在古墓丽影暗影中的表现
最近在关注这两个图形API,因为感兴趣,也算是初学者. 以下内容仅供参考. 使用古墓丽影暗影游戏,分别对这两个进行比较,得出的结论如下图(此笔记本散热很差,更改散热应该比下图结果好些): 首先看可以很 ...
- 第四模块:网络编程进阶&数据库开发 第1章·网络编程进阶
01-进程与程序的概念 02-操作系统介绍 03-操作系统发展历史-第一代计算机 04-操作系统发展历史-批处理系统 05-操作系统发展历史-多道技术 06-操作系统发展历史-分时操作系统 07-总结 ...
- C 计算员工工资
#include <stdio.h> int main(int argc, char **argv) { //定义四个变量 g每小时固定的工资 40 固定工作时间 pay工资 hours员 ...
- TCP/IP协议的学习笔记
1.OSI和TCP/IP的协议体系结构 OSI是开放系统互连参考模型,它的七层体系结构概念清楚,理论也比较完整,但它既复杂又不实用.而TCP/IP是一个四层的体系结构,它包含应用层.传输层.网际层和网 ...
- day21 TFRecord格式转换MNIST并显示
首先简要介绍了下TFRecord格式以及内部实现protobuf协议,然后基于TFRecord格式,对MNIST数据集转换成TFRecord格式,写入本地磁盘文件,再从磁盘文件读取,通过pyplot模 ...
- react创建新项目并且修改配置文件
react创建项目 这是我在用react搭建项目时,用到的一些东西,顺序纯属自己定义, 一.创建项目 用react 创建一个项目,这也是官方给出的 1.npm install create-react ...
- Netcore logging config
- FZU 1844 Earthquake Damage(最大流最小割)
Problem Description Open Source Tools help earthquake researchers stay a step ahead. Many geological ...