ABC053 C - X: Yet Another Die Game
備忘録
問題
回答
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array # from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall # from decimal import Decimal # from collections import defaultdict, deque sys.setrecursionlimit(10000000) ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda: list(map(int, sys.stdin.buffer.readline().split())) fl = lambda: list(map(float, sys.stdin.buffer.readline().split())) iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] iss = lambda: sys.stdin.buffer.readline().decode().rstrip() sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split())) isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] lcm = lambda x, y: (x * y) // math.gcd(x, y) MOD = 10 ** 9 + 7 INF = float('inf') def main(): if os.getenv("LOCAL"): sys.stdin = open("input.txt", "r") N = ii() d, m = divmod(N, 11) ret = d * 2 if m == 0: print(ret) elif m >= 7: print(ret + 2) else: print(ret + 1) if __name__ == '__main__': main()
考え方
最も効率よく、点数を得る方法を考えると、
初めは1, 6
以外の面を上に置き、
1度目の操作で6
を上にする。
次は5
を上にして、その次は6
・・・と、
6
と5
を交互に繰り返すのが最も効率よく、点数を得る。
2回の操作で最大11
得ることができるため、
11
で割ることによって、5
と6
を往復する回数を求めることができる。
あとは、端数(余り)の数が6
以上の場合には最低でも追加で2回の操作、
1
以上6
以下の場合には追加で1回の操作が必要となる。