Kattis - register 【水】

这里写图片描述

题意

就是 有一堆容器,然后可以执行加的操作,每个容量是
2, 3, 5, 7, 11, 13, 17, 19

然后 有进位 比如第一个 容器,到2了,就会重置为0,然后 下一个容器+ 1, 但是要保证 最后一个容器 不大于等于 19 就可以
算出 最多加多少次,从最低的容器开始加

思路

从后面往前推

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>

using namespace std;
typedef long long LL;

const double PI  = 3.14159265358979323846264338327;
const double E   = 2.718281828459;
const double eps = 1e-6;

const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e3 + 5;
const int MOD  = 1e9 + 7;

int n[] = {1, 2, 4, 6, 10, 12, 16, 18};
int a[8];

int main()
{
    int num;
    memset(a, 0, sizeof(a));
    for (int i = 0; i < 8; i++)
        scanf("%d", &a[i]);
    int ans = n[7] - a[7];
    for (int i = 6; i >= 0; i--)
    {
        ans += (n[i] - a[i]) + ans * n[i];
    }
    cout << ans << endl;
}
posted @ 2018-03-10 21:14  Dup4  阅读(122)  评论(0编辑  收藏  举报