Gym - 101775K - Downgrade(模拟)

版权声明:沃斯里德小浩浩啊 https://blog.csdn.net/Healer66/article/details/82559146

The God of Sheep plays an RPG game recently. The game has a level system that records a player's level with a pair of positive integers A and B where A is the major level and B is the minor level. For each major level k, you have to reach minor level Lk in order to upgrade to the next level k + 1. Different major levels may have different number of minor levels. For example, the God of Sheep is currently on level 3-4, and level 3 contains 4 minor levels: 3-1, 3-2, 3-3, and 3-4. Once the God of Sheep upgrades, he will be on level 4-1.

The God of Sheep has work to do now. Countless sheep are suffering in slaughter houses, woolsheds, and dairy farms. The God of Sheep has to rescue his fellow sheep citizens. He will be busy with the rescue plan for a couple of days and meanwhile the level of the game will be downgraded each day as a penalty. The downgrade penalty works like this: with each day the God of Sheep not playing the game, his level A-B will firstly be transformed to A minor levels (with minor level Bdiscarded), and then be cast to an equivalent - pair as his new level. For example, suppose both level 1 and level 2 have 2 minor levels, and the God of Sheep is currently on level 3-3. For the first day of his absence, the level will become 2-1, the second day the level will become 1-2, the third day the level will become 1-1, and from the third day on the level will keep the same level as 1-1.

The God of Sheep wonders which level will he be when he comes back from the rescue?

Input

The first line of the input gives the number of test cases, TT test cases follow.

Each test case contains two lines. The first line contains three integers: AB and N, indicating the current major level, minor level, and the number of days the God of Sheep will be away from the game. The next line contains A integers: L1, L2, ..., LA indicating the number of minor levels in each major level.

  • 1 ≤ T ≤ 20.
  • 1 ≤ A ≤ 105.
  • 1 ≤ B ≤ LA.
  • 1 ≤ Li, N ≤ 109.

Output

For each test case, output one line containing "Case #x: y-z", where x is the test case number (starting from 1), y and z are the major level and the minor level when the God of Sheep is back to the game.

Example

Input

2
3 2 2
2 2 2
3 1 2
1 1 1

Output

Case #1: 1-2
Case #2: 3-1

题意:

这道题最坑的地方就是题意了吧,到底怎么转化的来着,A-B就理解为等级A需要B经验才能升级,一天不玩,先将经验归零,然后将等级转化为经验,看当前经验够升到多少级多少经验。

思路:

纯模拟。

#include <bits/stdc++.h>
using namespace std;
const int  maxn =1e7+9;
typedef long long ll;
int sum[maxn];
int main()
{
    ios::sync_with_stdio(false);
   int t,A,B,n,k=1;
    cin>>t;
    while(t--)
    {
        cin>>A>>B>>n;
        for(int i=1;i<=A;i++)
            cin>>sum[i];
        int prea = A,preb = B;
        while(n--)
        {
          B = A;
          A = 1;
          while(B > sum[A])
          {
              B-=sum[A];
              A++;
          }
          if(A==prea&&B==preb) break;
          if(A==1&&B==1)  break;
          prea = A,preb = B;
        }
        printf("Case #%d: %d-%d\n",k++,A,B);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/Healer66/article/details/82559146
今日推荐