F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Umamusume

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 133    Accepted Submission(s): 62


Problem Description
"Makea newtrack" is a new mode of game "Umamusume".During the game,there will be $n$ rounds to improve attributes,each round can choose between rest,train or race.

$rest$:add 50 TP

$train$:spend 50 TP and add 15 speed points(TP less than 50 will fail)

$race$:spend 50 TP and add 100 G(TP less than 50 will fail)

At first round,you have 100 TP.

You can spend G in a special store to obtain items,special store will refresh the items that can be buy every 6 rounds(Round 6 will be the earliest time to buy items).The probability of each item appearing in the store is $p$(It can exist in a store and not sell anything and the number of one type of item is only one).Different item have different price and features:
|item name|price | function|
| -----------: | -----------: | -----------: |
|TP Medicine(L)|100G| add 100 TP|
|TP Medicine(M)|50G| add 50 TP|
|TP Medicine(S)|25G| add 25 TP|
|Magic Book(L)|100G| add 15 speed points|
|Magic Book(M)|50G| add 7 speed points|
|Magic Book(S)|25G| add 3 speed points|
|Horn|100G| next training speed points will become 2x|
|Weight|200G| next training speed points will spend 100 TP but become 3x|
(Weight can not be used together with Horn)

Each item can be bought more than one time and you can use the item on any round after you buy it.

In order to obtain the strongest and fastest umamusume in the game,you know all the items in the store at first,and you are smart.You want to know the expected speed points.

Please output it modulo $10^9+7$.
 

Input
The input consists of multiple test cases. The first line contains a single integer $T(1 \leq T \leq 10000)$ — the number of test cases.

The each test case contains contains two integers $n $and $p $ $(0 \leq n \leq 10^9,0 \leq p < 10^9+7)$—This means that the number of rounds and the probability of each item appearing in the store.

 

Output
For each test case, output an integer representing the expected speed points modulo $10^9+7$.
 

Sample Input
3 2 1 5 500000004 27 500000004
 

Sample Output
30 45 857330545
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-03 15:29:34, Gzip enabled