Submission #7588642
Source Code Expand
#ifndef ENV_AC
#define ENV_AC
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>
#include <ext/rope>
using int128_t = __int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
int64_t tmp; input >> tmp; value = tmp;
return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
output << (int64_t)value;
return output;
}
namespace std {
template<> class hash<int128_t>{
public:
size_t operator () ( const int128_t &x ) const {
int64_t INF64 = std::numeric_limits<int64_t>::max();
int64_t y1 = x / INF64;
int64_t y2 = x % INF64;
return hash<int64_t>()(y1) ^ hash<int64_t>()(y2);
}
};
}
int128_t imax(const int128_t a, const int128_t b) { return std::max(a, b); } // std::max, std::min は型が違うとエラーになるため、ラッパーを作る。
int128_t imin(const int128_t a, const int128_t b) { return std::min(a, b); }
int128_t iabs(const int128_t x) { return 0 <= x ? x : -x; }
int128_t ipow(const int128_t x, const int128_t n) { int128_t ret = 1; for (int i = 0; i < n; i++) { ret *= x; } return ret; }
template <int128_t mod> class Mod_Int {
public:
int128_t val;
void calc() {
if (val < 0) { val += ((iabs(val) + mod) / mod) * mod; }
val %= mod;
}
Mod_Int(const int128_t _val = 0) { val = _val; calc(); }
int128_t INT() { return val; } // 使用は非想定
int128_t MOD() { return mod; } // 使用は非想定
Mod_Int operator-() const { return Mod_Int(-val); }
Mod_Int operator+(const Mod_Int &r) const { return Mod_Int(val + r.val); }
Mod_Int operator-(const Mod_Int &r) const { return Mod_Int(val - r.val); }
Mod_Int operator*(const Mod_Int &r) const { return Mod_Int(val * r.val); }
//Mod_Int operator/(const Mod_Int &r) const { return ; } // ユークリッド互除法を使うべきだが保留。
Mod_Int& operator+=(const Mod_Int &r) { val += r.val; calc(); return *this; }
Mod_Int& operator-=(const Mod_Int &r) { val -= r.val; calc(); return *this; }
Mod_Int& operator*=(const Mod_Int &r) { val *= r.val; calc(); return *this; }
Mod_Int& operator++() { return (*this) += 1; }
Mod_Int& operator--() { return (*this) -= 1; }
Mod_Int operator++(int) { Mod_Int tmp = *this; ++*this; return tmp; }
Mod_Int operator--(int) { Mod_Int tmp = *this; --*this; return tmp; }
bool operator==(const Mod_Int &r) const { return val == r.val; }
bool operator!=(const Mod_Int &r) const { return val != r.val; }
friend std::istream &operator>>(std::istream& input, Mod_Int& r) {
int128_t tmp; input >> tmp;
r = Mod_Int(tmp);
return input;
}
friend std::ostream &operator<<(std::ostream& output, const Mod_Int& r) {
output << r.val;
return output;
}
};
// binary search result
struct BSR {
bool found; // 条件を満たす範囲が見つかったか。falseの場合、begin,endは意味を持たない。
int128_t begin; // [begin, end]で条件が成り立つ。
int128_t end;
BSR(bool found_in, int128_t begin_in, int128_t end_in) { found = found_in; begin = begin_in; end = end_in; }
};
//template<class Fn> BSR binary_search(int128_t L, int128_t R, Fn func) {
BSR binary_search(int128_t L, int128_t R, std::function<bool(int128_t)> func) {
const bool res_L = func(L);
const bool res_R = func(R);
if (res_L && res_R) {
return BSR(true, L, R);
} else if (!res_L && !res_R) {
return BSR(false, 0, 0);
} else {
int128_t lb = L;
int128_t ub = R;
while (lb + 1 < ub) {
int128_t mid = (lb + ub) / 2;
if (res_L == func(mid)) {
lb = mid;
} else {
ub = mid;
}
}
return res_L ? BSR(true, L, lb) : BSR(true, ub, R);
}
}
#define rep(i, begin, end) for(int64_t i = ((int64_t)begin); i <= ((int64_t)end); i++) // (int64_t)end としておくと、end = v.size() - 2 みたいな入力で、v.size()が1でも正常(end = -1になる)に挙動する。
#define rev(i, begin, end) for(int64_t i = ((int64_t)begin); ((int64_t)end) <= i; i--) // int128_tにすると、3重ループでコンパイルエラーになったのでint64_tにしておく。
#define input1(begin, end, v1) v1.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i]; }
#define input2(begin, end, v1, v2) v1.resize((end)+1); v2.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i]; }
#define input3(begin, end, v1, v2, v3) v1.resize((end)+1); v2.resize((end)+1); v3.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i] >> v3[i]; }
#define input4(begin, end, v1, v2, v3, v4) v1.resize((end)+1); v2.resize((end)+1); v3.resize((end)+1); v4.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i] >> v3[i] >> v4[i]; }
#define input5(begin, end, v1, v2, v3, v4, v5) v1.resize((end)+1); v2.resize((end)+1); v3.resize((end)+1); v4.resize((end)+1); v5.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i] >> v3[i] >> v4[i] >> v5[i]; }
// input_arrayはbegin = 0のときのみ動作確認。Aの要素の型をテンプレートにして関数にしたほうが丁寧かもしれない。
#define input_array(begin, N, M, A) A.resize((begin)+(N)); for (int i = 0; i < (begin)+(N); i++) { A[i].resize((begin)+(M)); } for (int i = begin; i < (begin)+(N); i++) { for (int j = begin; j < (begin)+(M); j++) { std::cin >> A[i][j]; }}
std::vector<int128_t> irange(const int128_t begin, const int128_t end) {
std::vector<int128_t> ret; for (int128_t i = begin; i <= end; i++) { ret.push_back(i); }
return ret;
}
template <typename T>
std::vector<T> accumulate_vec(const std::vector<T>& vec, const bool reverse = false) {
std::vector<T> ret; ret.resize(vec.size());
if (reverse == false) {
ret[0] = vec[0];
for (int i = 1; i < ret.size(); i++) {
ret[i] = ret[i-1] + vec[i];
}
} else {
ret[ret.size()-1] = vec[ret.size()-1];
for (int i = ret.size() - 2; 0 <= i; i--) {
ret[i] = ret[i+1] + vec[i];
}
}
return ret;
}
template <typename T>
T cal_pow(T x, int128_t n, T tmp = T(1)) {
// 累乗の計算。
while (n > 0) {
if (n & 1) { tmp = tmp * x; }
x = x * x;
n = (n >> 1);
}
return tmp;
}
std::vector<int128_t> digit(int128_t n, const int128_t b) {
// 基数bでの表示。0は0桁。非常に大きい数を入れても問題ないようにint128_tとする。
// size()をとれば桁数になる。
assert(1 < b);
std::vector<int128_t> ret;
while (0 < n) {
ret.push_back(n % b);
n /= b;
}
return ret;
}
template <typename T>
void printvec(const std::vector<T>& vec) {
for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}
#endif
//--code begin--
int128_t N;
std::vector<int128_t> A;
//std::string S;
//std::vector<std::string> ;
//double A, B, H, W;
//std::vector<double> ;
//const int128_t MAX_N = 1e5 + 10;
//const int128_t MOD = ;
//const int128_t INF = std::numeric_limits<int64_t>::max(); const int128_t NEG_INF = std::numeric_limits<int64_t>::min();
//using pair = std::pair<int64_t, int>;
//using mnt = Mod_Int<MOD>;
int main(int argc, char **argv) {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::cout << std::fixed << std::setprecision(15);
std::cin >> N;
input1(1, N, A);
int128_t ret = 0;
rep (i, 1, N) {
if (A[i]%6 == 2) {
ret += 1;
} else if (A[i]%6 == 1 || A[i]%6 == 3) {
continue;
} else if (A[i]%6 == 0) {
ret += 3;
} else {
ret += A[i]%6 - 3;
}
}
std::cout << ret << std::endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
B - 花占い |
User |
critter |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
9362 Byte |
Status |
AC |
Exec Time |
3 ms |
Memory |
384 KB |
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
All |
sample_01.txt, sample_02.txt, test_1.txt, test_112358.txt, test_1379137913.txt, test_1414213562.txt, test_1732151817.txt, test_2.txt, test_2236167977.txt, test_2645751311.txt, test_3.txt, test_3141592653.txt, test_4.txt, test_5.txt, test_6.txt, test_6666666666.txt, test_7.txt, test_73.txt, test_8.txt, test_9.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
AC |
3 ms |
384 KB |
sample_02.txt |
AC |
1 ms |
256 KB |
test_1.txt |
AC |
1 ms |
256 KB |
test_112358.txt |
AC |
1 ms |
256 KB |
test_1379137913.txt |
AC |
1 ms |
256 KB |
test_1414213562.txt |
AC |
1 ms |
256 KB |
test_1732151817.txt |
AC |
1 ms |
256 KB |
test_2.txt |
AC |
1 ms |
256 KB |
test_2236167977.txt |
AC |
1 ms |
256 KB |
test_2645751311.txt |
AC |
1 ms |
256 KB |
test_3.txt |
AC |
1 ms |
256 KB |
test_3141592653.txt |
AC |
1 ms |
256 KB |
test_4.txt |
AC |
1 ms |
256 KB |
test_5.txt |
AC |
1 ms |
256 KB |
test_6.txt |
AC |
1 ms |
256 KB |
test_6666666666.txt |
AC |
1 ms |
256 KB |
test_7.txt |
AC |
1 ms |
256 KB |
test_73.txt |
AC |
1 ms |
256 KB |
test_8.txt |
AC |
1 ms |
256 KB |
test_9.txt |
AC |
1 ms |
256 KB |