Submission #18154


Source Code Expand

Copy
/*
  A.cpp
 */

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef int int_type;

// -- utility --
// C-style loop
#define FOR(x, a, b) for(int_type x = static_cast<int_type>(a); x < static_cast<int_type>(b); ++x)
#define FORN(x, n) FOR(x, 0, n)
// Ruby-style loop
#define TIMES(x, n) FOR(x, 0, n)
#define STEP(x, a, b, s) for(int_type x = static_cast<int_type>(a); s > 0 ? x <= static_cast<int_type>(b) : x >= static_cast<int_type>(b); x += static_cast<int_type>(s) )
#define UPTO(x, a, b) for(int_type x = static_cast<int_type>(a); x <= static_cast<int_type>(b); ++x)
#define DOWNTO(x, a, b) for(int_type x = static_cast<int_type>(a); x >= static_cast<int_type>(b); --x)
#define EACH(c, i) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(cont, it, cond, ret) \
  bool ret = true; EACH(cont, it) { if(!(cond)) {ret=false;break;} }
#define ANY(cont, it, cond, ret) \
  bool ret = false; EACH(cont, it) { if(cond) {ret=true;break;} }


// debug
#define DUMP(x) std::cout << #x << " = " << to_s(x) << std::endl;

using namespace std;

template<typename T> string to_s(const T& v);
template<> string to_s(const string& v);
template<> string to_s(const bool& v);
template<typename T> string to_s(const vector<T>& v);
template<typename T> string to_s(const list<T>& v);
template<typename T> string to_s(const set<T>& v);
template<typename F, typename S> string to_s(const pair<F,S>& v);
template<typename K, typename V> string to_s(const map<K,V>& v);


int main(int argc, char *argv[])
{

  int n;
  cin >> n;

  string s;
  cin >> s;

  int total = 0;
  
  TIMES(i, s.size()) {
    if(s[i] == 'A') {
      total += 4;
    }else if(s[i] == 'B') {
      total += 3;
    }else if(s[i] == 'C') {
      total += 2;
    }else if(s[i] == 'D') {
      total += 1;
    }else if(s[i] == 'F') {
      total += 0;
    }
  }

  cout << setprecision(12) <<  (1.0 * total / n) << endl;
  
  return 0;
}


template<typename T> string to_s(const T& v) { ostringstream oss; oss << v; return oss.str(); }
template<> string to_s(const string& v) { ostringstream oss; oss << '"' << v << '"'; return oss.str(); }
template<> string to_s(const bool& v) { ostringstream oss; oss << ( v ? "true" : "false") ; return oss.str(); } 
template<typename T> string to_s(const vector<T>& v) { ostringstream oss; oss << "["; EACH(v,i) oss << to_s(*i) << ","; oss << "]"; return oss.str(); }
template<typename T> string to_s(const list<T>& v) { ostringstream oss; oss << "("; EACH(v,i) oss << to_s(*i) << ","; oss << ")"; return oss.str(); }
template<typename T> string to_s(const set<T>& v) { ostringstream oss; oss << "{"; EACH(v,i) oss << to_s(*i) << ","; oss << "}"; return oss.str(); }
template<typename F, typename S> string to_s(const pair<F,S>& v) { ostringstream oss; oss << "<" << to_s(v.first) << " " << to_s(v.second) << ">"; return oss.str(); }
template<typename K, typename V> string to_s(const map<K,V>& v) { ostringstream oss; oss << "{"; EACH(v,i) oss << to_s(i->first) << " => " << to_s(i->second) << ","; oss << "}"; return oss.str(); }

Submission Info

Submission Time
Task A - GPA計算
User wataken44
Language C++ (GCC 4.4.7)
Score 100
Code Size 3466 Byte
Status AC
Exec Time 55 ms
Memory 892 KB

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 32
Set Name Test Cases
all 00_sample_01.txt, 00_sample_02.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 02_rndmax_01.txt, 02_rndmax_02.txt, 02_rndmax_03.txt, 02_rndmax_04.txt, 02_rndmax_05.txt, 02_rndmax_06.txt, 02_rndmax_07.txt, 02_rndmax_08.txt, 02_rndmax_09.txt, 02_rndmax_10.txt, 03_mini_01.txt, 03_mini_02.txt, 03_mini_03.txt, 03_mini_04.txt, 03_mini_05.txt, 04_samemax_01.txt, 04_samemax_02.txt, 04_samemax_03.txt, 04_samemax_04.txt, 04_samemax_05.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 25 ms 780 KB
00_sample_02.txt AC 25 ms 776 KB
01_rnd_01.txt AC 25 ms 776 KB
01_rnd_02.txt AC 23 ms 764 KB
01_rnd_03.txt AC 23 ms 784 KB
01_rnd_04.txt AC 24 ms 780 KB
01_rnd_05.txt AC 23 ms 744 KB
01_rnd_06.txt AC 21 ms 776 KB
01_rnd_07.txt AC 26 ms 784 KB
01_rnd_08.txt AC 23 ms 780 KB
01_rnd_09.txt AC 26 ms 804 KB
01_rnd_10.txt AC 24 ms 784 KB
02_rndmax_01.txt AC 25 ms 792 KB
02_rndmax_02.txt AC 24 ms 816 KB
02_rndmax_03.txt AC 23 ms 780 KB
02_rndmax_04.txt AC 23 ms 776 KB
02_rndmax_05.txt AC 23 ms 780 KB
02_rndmax_06.txt AC 55 ms 780 KB
02_rndmax_07.txt AC 30 ms 744 KB
02_rndmax_08.txt AC 24 ms 756 KB
02_rndmax_09.txt AC 26 ms 892 KB
02_rndmax_10.txt AC 25 ms 788 KB
03_mini_01.txt AC 23 ms 772 KB
03_mini_02.txt AC 24 ms 776 KB
03_mini_03.txt AC 21 ms 760 KB
03_mini_04.txt AC 26 ms 812 KB
03_mini_05.txt AC 21 ms 776 KB
04_samemax_01.txt AC 24 ms 784 KB
04_samemax_02.txt AC 38 ms 784 KB
04_samemax_03.txt AC 24 ms 760 KB
04_samemax_04.txt AC 23 ms 744 KB
04_samemax_05.txt AC 23 ms 772 KB