UVa 12403 - Save Setu

题目:有两种操作:1.当前数值增加;2.输出当前数值。

分析:简单题。模拟即可。

说明:A+B。

#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

string s;

int main()
{
	int n,sum,add;
	while (cin >> n) {
		sum = 0;
		while (n --) {
			cin >> s;
			if (s[0] == 'd') {
				cin >> add;
				sum += add;
			}else
				cout << sum << endl;
		}
	}
	return 0;
}
时间: 2024-10-10 01:21:32

UVa 12403 - Save Setu的相关文章

UVA - 11986 Save from Radiation

Description J Save from Radiation Most of you are aware of Nuclear Power Plant Explosion at Fukushima after devastating earth quake and tsunami. Many people in Bangladesh were seen to be concerned with radiation. The message says: BBC Flash news: Jap

UVA 11292 Dragon of Loowater(简单贪心)

Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predato

uva 11292

A - Dragon of Loowater Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVA 11292 Appoint description:  System Crawler  (2014-11-26) Description Problem C: The Dragon of Loowater Once upon a time, in the K

UVa 10679 - I Love Strings!!

题目:给你一个目标串,和一些模式串,问每个模式串是否在目标串中出现. 分析:字符串,AC自动机.一开始用KMP算法,TLE了才发现会超时,改用AC自动机: 直接利用AC自动机存储,查询即可,然后按顺序输出: 如果模式串中有重复的,直接利用并查集合并即可,只须判断父节点. 说明:╮(╯▽╰)╭计算复杂度时,数据组数被忽略了:注意初始化. #include <iostream> #include <cstdlib> #include <cstring> #include &

UVA 1341 - Different Digits(数论)

UVA 1341 - Different Digits 题目链接 题意:给定一个正整数n,求一个kn使得kn上用的数字最少,如果相同,则输出值最小的 思路: 首先利用鸽笼原理证明最多需要2个数字去组成 设一个数字k,组成k,kk,kkk,kkkk... %n之后余数必然在0 - (n - 1)之间,所以必然能选出两个余数相等的数字相减为0,这个数字就是由0和k组成的. 因此只要考虑一个数字和两个数字的情况,去bfs,记忆化余数,因为余数重复必然形成周期了 代码: #include <stdio.

UVa 10087 - The Tajmahal of ++Y2k

l and dished out an assist in the Blackhawks' 5-3 win over the Nashville Predators.Shaw said just playing with the Blackhawks was enough motivation for him."Positive, I'm playing in the NHL," Shaw said after Sunday's win. "What can't you be

UVA之11292 Dragon of Loowater

Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predato

UVa 10599【lis dp,记忆化搜索】

UVa 10599 题意: 给出r*c的网格,其中有些格子里面有垃圾,机器人从左上角移动到右下角,只能向右或向下移动.问机器人能清扫最多多少个含有垃圾的格子,有多少中方案,输出其中一种方案的格子编号.格子编号是从 左上角第一个开始,一行一行的按自然数顺序编.起始行列是第一行第一列.所以例如一个格子的行列号为(ro,co),那么它的编号为bh=(ro-1)*column+co,其中column指这个格子有多少列.(我觉得原题里面有个错误,题目叙述倒数第二行应该是41(6,6)不是41(6,7)).

UVA 322 ships (POJ 1138)

题目地址: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=258 http://poj.org/problem?id=1138 题目描写叙述:  Ships  Probably everyone who ever attended school knows the game where two opposing players place