题目大意:
多组输入,每组10个数据,默认段位是黄金,询问是否能上王者,7表示掉了一大段,1表示生了一大段,0表示不变,对于已经青铜和已经王者来说不存在升段和掉段。
解题思路:
简单模拟,用3代表黄金,每次升段掉段用±1表示,判断最后是否能到达7(王者),如果早就到达7了,则1和0一个意义,如果早就到达1了那么0和7一个意义。判断一下当前是否到临界值然后根据情况升段掉段就可以了。AC代码:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
const int mod = 1e9 + 7;
const int N = 5e5+50;
typedef long long ll;
typedef pair<int, int> pii;
int main()
{
while (true)
{
int a[15], s = 3;
for (int i = 1; i <= 10; i ++)
{
if (! (cin >> a[i]))
return 0;
}
for (int i = 1; i <= 10; i++)
{
if (a[i] == 0) continue;//0表示不变
else if (a[i] == 1 && s < 7)//如果没到王者则可以升段
s++;
else if (a[i] == 7 && s > 1)//如果没到青铜则可以继续掉段
s--;
}
cout << (s == 7 ? 666 : 777 )<< endl;
}
return 0;
}