poj 3094 Quicksum

简介:

除了这道题真的很水,我好像也不能说别的什么了吧。。。哈哈哈,注意一下控制一下循环的细节就好,一个连乘的累加


#include <stdio.h>
#include <string.h>

int main()
{
	char str[300];
	int sum,pos;
	
	while(gets(str))
	{
		if(str[0]=='#')
			break;
		
		//计算quicksum值
		pos=0;
		sum=0;
		while(str[pos]!='\0')
		{
			if(str[pos]==' ')
				pos++;
			
			else
			{
				sum+=(pos+1)*(str[pos]-'A'+1);
				pos++;
			}
		}
		
		printf("%d\n",sum);
	}
	
	return 0;
}


相关文章
poj 2299 求逆序数
http://poj.org/problem?id=2299 #include using namespace std; int aa[500010],bb[500010]; long long s=0; void merge(int l,int m,int r) { ...
767 0
poj-3094-quicksum
http://poj.org/problem?id=3094 很简单 #include #include using namespace std; int main() { string a; int sum=0; while(getline(cin...
551 0
POJ 2262 Goldbach&#39;s Conjecture
Problem Description In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the foll...
968 0
|
机器学习/深度学习
|
SDN
poj 2886 Who Gets the Most Candies?
点击打开poj 2886 思路: 求因子数+单点更新 分析: 1 题目的意思是有n个人构成一个环,刚开始是第k个人先出来。每个人有一个名字和数值A,如果A为正数,那么下一个出去的人是他左边的第A个人,如果是负数那么出去的将是右边的第A个人 2 这么我们要注意一下,因为n个人是围城一圈,那么左边就是顺时针方向,右边就是逆时针方向 3 那么我们就可以来推没一次出去的人的在剩下中是第几个。
764 0
POJ 1011
http://www.cnblogs.com/linpeidong2009/archive/2012/04/23/2467048.html http://blog.163.com/xdu_cfcry/blog/static/1694623032010718274132/
620 0

热门文章

最新文章