Quicksum

From Progteam

Revision as of 23:22, 19 August 2008 by Mlc413 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Checkmark.jpg This problem has been solved by mlc413.


Quicksum
Problem Number 3094
Sorter: meeting
Source: Unknown
Link: http://acm.pku.edu.cn/JudgeOnline/problem?id=3094



Quicksum is problem number 3094 on the Peking University ACM site.

import java.util.*;

public class Main{

    public static Scanner in;
 
    public static void main(String[] args){
        in=new Scanner(System.in);

        doStuff();
    }

    public static void doStuff(){
        String N=in.nextLine();


	while(N.charAt(0)!='#'){
	    solve(N);
	    N=in.nextLine();
	}
        
    }

    public static void solve(String N){
	int len=N.length();
	int sum=0;

	for(int i = 1; i <= len;i++){
	    char ch = N.charAt(i-1);
	    if(ch  != ' '){
		sum += i*(ch-'A'+1);	
	    }
	    
	}
	System.out.println(sum);
	
    }
}

Personal tools