POJ - 3094 - Quicksum = 水题

http://poj.org/problem?id=3094

学习fgets的使用,注意fgets是会连换行一起保存的。

#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

char s[10000];

int main() {
#ifdef Yinku
    freopen("Yinku.in", "r", stdin);
#endif // Yinku
    while(1) {
        fgets(s + 1, 10000 - 1, stdin);
        if(s[1] == '#')
            break;
        ll sum = 0;
        int n = strlen(s + 1);
        for(int i = 1; i <= n; ++i) {
            if(isupper(s[i]))
                sum += 1ll * i * (s[i] - 'A' + 1);
        }
        printf("%lld\n", sum);
    }
}

原文地址:https://www.cnblogs.com/Inko/p/11723405.html

时间: 2024-08-06 11:12:13

POJ - 3094 - Quicksum = 水题的相关文章

POJ 3094 Quicksum(简单题)

[题意简述]:题意很简单.看例子就能理解 [分析]:略.字符串的读取操作. // 200K 0Ms #include<iostream> using namespace std; int main() { char a[256]; while(1) { int sum = 0; gets(a); if(strcmp(a,"#")==0) break; int len = strlen(a); for(int i = 0;i<len;i++) { if(a[i] ==

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

poj 3264 RMQ 水题

题意:找到一段数字里最大值和最小值的差 水题 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #include<cmath> 6 #include<queue> 7 using namespace std; 8 const int maxn=550; 9 const int INF=0x3f3f3f3f; 10 in

poj 1979 dfs水题

// 练练水题,夯实基础吧 #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib

POJ 3094 Quicksum 难度:0

http://poj.org/problem?id=3094 1 #include<iostream> 2 #include <string> 3 using namespace std; 4 int main() 5 { 6 string str; 7 getline(cin,str); 8 while(str != "#") 9 { 10 int ans = 0; 11 for(int i = 0;i < str.length(); i++) 12 {

POJ 1000(水题)

这道题就很水啦,只要看懂题...所以我受了这个影响,再去hoj的时候想都没想就还按照这个打了,结果就像之前那篇说的那样WA. #include <stdio.h> int main() { int a,b; scanf("%d %d",&a, &b); printf("%d\n",a+b); return 0; }

POJ - 3090 gcd水题

大概题意就是求\(1 \le i,j \le n\)的\(gcd(i,j) = 1\)的个数+2(对于0的特判) 正解应该是欧拉函数或者高逼格的莫比乌斯反演 但数据实在太水直接打表算了 /*H E A D*/ bool GCD[1002][1002]; inline int gcd(int a,int b){return b?gcd(b,a%b):a;} int main(){ rep(i,1,1000) rep(j,1,1000) GCD[i][j]=bool(gcd(i,j)==1); in

POJ 3094 Quicksum(简单的问题)

[简要题意]:题意是非常easy. 看样能理解 [分析]:略. 读取字符串. // 200K 0Ms #include<iostream> using namespace std; int main() { char a[256]; while(1) { int sum = 0; gets(a); if(strcmp(a,"#")==0) break; int len = strlen(a); for(int i = 0;i<len;i++) { if(a[i] ==

poj 3094 Quicksum

#include <stdio.h> #include <string.h> char word[301]; int main() { int sum = 0; int i,len; while(gets(word)) { sum = 0; if(word[0] == '#') break; len = strlen(word); for(i = 0; i < len; ++i) { if(word[i] != ' ') sum += (i+1) * (word[i]-'A'