• SOJ.DiceGame

2015-03-29 19:33:21
1000. Dice Game     总提交数量： 100 通过数量： 59                 时间限制：1秒 内存限制：256兆 题目描述 Gunnar and Emma play a lot of b


1000. Dice Game

总提交数量：
100
通过数量：
59

时间限制：1秒    内存限制：256兆
题目描述

Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6- sided dice. For example they own a die that has 10 sides with numbers 47, 48, ..., 56 on it.
There has been a big storm in Stockholm, so Gunnar and Emma have been stuck at home without electricity for a couple of hours. They have finished playing all the games they have, so they came up with a new one. Each player has 2 dice which he or she rolls.
The player with a bigger sum wins. If both sums are the same, the game ends in a tie.
Given the description of Gunnar’s and Emma’s dice, which player has higher chances of winning?
All of their dice have the following property: each die contains numbers a, a + 1, ..., b, where a and b are the lowest and highest numbers respectively on the die. Each number appears exactly on one side, so the die has b - a + 1 sides.

输入格式

The first line contains four integers a1, b1, a2, b2 that describe Gunnar’s dice. Die number i contains numbers ai, ai + 1, ..., bi on its sides. You may assume that 1 <= ai <= bi <= 100. You can further assume that each die has at least four sides, so
ai + 3 <= bi. The second line contains the description of Emma’s dice in the same format.

输出格式

Output the name of the player that has higher probability of winning. Output “Tie” if both players have same probability of winning.

样例输入
将样例输入复制到剪贴板

样例一：
1 4 1 4
1 6 1 6
样例二：
1 8 1 8
1 10 2 5
样例三：
2 5 2 7
1 5 2 5

样例输出

样例一：
Emma
样例二：
Tie
样例三：
Gunnar

Problem Source: 2015年每周一赛第四场

挺水的一道题，看平均值就好

#include
using namespace std;
int main(){
double a,b,c,d,e,f,g,h,sum1,sum2;
cin>>a>>b>>c>>d>>e>>f>>g>>h;
sum1=((a+b)/2)+((c+d)/2);
sum2=((e+f)/2)+((g+h)/2);
if(sum1==sum2)cout<<"Tie"<sum2)cout<<"Gunnar"<


展开全文
• D - DiceGame

2018-08-31 18:06:45
A dice is a small cube, with each side having a different number of spots on it, ranging from 1 to 6. Each side in the dice has 4 adjacent sides that can be reached by rotating the dice (...
Statements

A dice is a small cube, with each side having a different number of spots on it, ranging from 1 to 6.

Each side in the dice has 4 adjacent sides that can be reached by rotating the dice (i.e. the current side) 90 degrees. The following picture can help you to conclude the adjacent sides for each side in the dice.

In this problem, you are given a dice with the side containing 1 spot facing upwards, and a sum n, your task is to find the minimum number of required moves to reach the given sum.

On each move, you can rotate the dice 90 degrees to get one of the adjacent sides to the side that currently facing upwards, and add the value of the new side to your current sum. According to the previous picture, if the side that currently facing upwards contains 1 spot, then in one move you can move to one of sides that contain 2, 3, 4, or 5 spots.

Initially, your current sum is 0. Even though at the beginning the side that containing 1 spot is facing upwards, but its value will not be added to your sum from the beginning, which means that you must make at least one move to start adding values to your current sum.

Input

The first line contains an integer T (1 ≤ T ≤ 200), where T is the number of test cases.

Then T lines follow, each line contains an integer n (1 ≤ n ≤ 104), where n is the required sum you need to reach.

Output

For each test case, print a single line containing the minimum number of required moves to reach the given sum. If there is no answer, print -1.

Example

Input

2
5
10

Output

1
2

Note

In the first test case, you can rotate the dice 90 degrees one time, and make the side that contains 5 spots facing upwards, which make the current sum equal to 5. So, you need one move to reach sum equal to 5.

In the second test case, you can rotate the dice 90 degrees one time, and make the side that contains 4 spots facing upwards, which make the current sum equal to 4. Then rotate the dice another 90 degrees, and make the side that contains 6 spots facing upwards, which make the current sum equal to 10. So, you need two moves to reach sum equal to 10.

#include <iostream>
#include<stdio.h>
using namespace std;
typedef long long ll;
int main()
{int x,n,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
if(n==1)printf("-1\n");
else if(n==7)printf("3\n");
else
{
int ans=n/11*2;
x=n%11;
if(x<=5)ans++;
else ans+=2;
if(x==0)ans--;
printf("%d\n",ans);
}
}
return 0;
}


展开全文
• 13907. Dice Game Constraints Time Limit: 1 secs, Memory Limit: 256 MB Description Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6- side


13907. Dice Game

Constraints

Time Limit: 1 secs, Memory Limit: 256 MB

Description

Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6- sided dice. For example they own a die that has 10 sides with numbers 47, 48, ..., 56 on it.

There has been a big storm in Stockholm, so Gunnar and Emma have been stuck at home without electricity for a couple of hours. They have finished playing all the games they have, so they came up with a new one. Each player has 2 dice which he or she rolls.
The player with a bigger sum wins. If both sums are the same, the game ends in a tie.

Given the description of Gunnar’s and Emma’s dice, which player has higher chances of winning?

All of their dice have the following property: each die contains numbers a, a + 1, ..., b, where a and b are the lowest and highest numbers respectively on the die. Each number appears exactly on one side, so the die has b - a + 1 sides.

Input

The first line contains four integers a1, b1, a2, b2 that describe Gunnar’s dice. Die number i contains numbers ai, ai + 1, ..., bi on its sides. You may assume that 1 <= ai <= bi <= 100. You can further assume that each die has at least four sides, so ai
+ 3 <= bi. The second line contains the description of Emma’s dice in the same format.

Output

Output the name of the player that has higher probability of winning. Output “Tie” if both players have same probability of winning.

Sample Input

样例一：
1 4 1 4
1 6 1 6
样例二：
1 8 1 8
1 10 2 5
样例三：
2 5 2 7
1 5 2 5

Sample Output

样例一：
Emma
样例二：
Tie
样例三：
Gunnar

Problem Source

2015年每周一赛第四场

// Problem#: 13907
// Submission#: 3660104
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <stdio.h>

int main() {
int a1, b1, a2, b2, a3, b3, a4, b4;
double g = 0, e = 0;
scanf("%d%d%d%d%d%d%d%d", &a1, &b1, &a2, &b2, &a3, &b3, &a4, &b4);
for (int i = a1; i <= b1; i++)
for (int j = a2; j <= b2; j++) g += i + j;
for (int i = a3; i <= b3; i++)
for (int j = a4; j <= b4; j++) e += i + j;
printf(g / ((b1 - a1 + 1) * (b2 - a2 + 1)) > e / ((b4 - a4 + 1) * (b3 - a3 + 1)) ? "Gunnar\n" : (g / ((b1 - a1 + 1) * (b2 - a2 + 1)) < e / ((b4 - a4 + 1) * (b3 - a3 + 1)) ? "Emma\n" : "Tie\n"));
return 0;
}                                 

展开全文
• http://codeforces.com/gym/101532/problem/Emeet in the middle 分成两份 然后后一份最终得到的A需要得到X时的BA*B = X mod (1e9+7) B = X*(inv[A]) mod (1e9+7)#include #include #include ...
http://codeforces.com/gym/101532/problem/E

meet in the middle

分成两份 然后后一份最终得到的A需要得到X时的B

A*B = X mod (1e9+7)
B = X*(inv[A]) mod (1e9+7)

#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
#include <bitset>
using namespace std;
#define pb push_back
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define sld(n) scanf("%lld",&n)
#define sldd(n,m) scanf("%lld%lld",&n,&m)
#define slddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define sf(n) scanf("%lf",&n)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define ss(str) scanf("%s",str)
#define ans() printf("%d",ans)
#define ansn() printf("%d\n",ans)
#define anss() printf("%d ",ans)
#define lans() printf("%lld",ans)
#define lanss() printf("%lld ",ans)
#define lansn() printf("%lld\n",ans)
#define fansn() printf("%.10f\n",ans)
#define r0(i,n) for(int i=0;i<(n);++i)
#define r1(i,e) for(int i=1;i<=e;++i)
#define rn(i,e) for(int i=e;i>=1;--i)
#define rsz(i,v) for(int i=0;i<(int)v.size();++i)
#define szz(x) ((int)x.size())
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define lowbit(a) (a&(-a))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(aa,bb) make_pair(aa,bb)
#define lrt rt<<1
#define rrt rt<<1|1
#define X first
#define Y second
#define PI (acos(-1.0))
#define sqr(a) ((a)*(a))
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000000+7;
const double eps=1e-9;
const int inf=0x3f3f3f3f;
const ll infl = 10000000000000000;
const int maxn=  100+10;
const int maxm = 6000+10;
//Pretests passed
int in(int &ret)
{
char c;
int sgn ;
if(c=getchar(),c==EOF)return -1;
while(c!='-'&&(c<'0'||c>'9'))c=getchar();
sgn = (c=='-')?-1:1;
ret = (c=='-')?0:(c-'0');
while(c=getchar(),c>='0'&&c<='9')ret = ret*10+(c-'0');
ret *=sgn;
return 1;
}

int a[maxn][10];
ll qpow(ll k,ll x)
{
ll res = 1;
ll base = x;
while(k)
{
if(k&1)res=res*base%mod;
base = base*base %mod;
k>>=1;
}
return res;
}
map<ll,int>ma;int n,x;
void dfs(int cur,int last,ll now)
{
if(!last)
{
ma[now]++;
return ;
}
for(int i=1;i<=6;++i)dfs(cur+1,last - 1, now*a[cur][i]%mod);

}
ll ans = 0;
void dfs2(int cur,ll now)
{
if(cur==n+1)
{
ll inv = qpow(mod-2,now);
//        ll check = x%now==0?x/now:0;
//        ll cnt = ma[check];
//        ans +=cnt;
inv = inv*x%mod ;
ll cnt = ma[inv];
ans += cnt;
return ;
}
r1(i,6)dfs2(cur+1,now*a[cur][i]%mod);
}
int main()
{
#ifdef LOCAL
freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif // LOCAL

int t;
sd(t);
while(t--)
{
//        int n,x;
ans  = 0;
sdd(n,x);
r1(i,n)r1(j,6)sd(a[i][j]);
ma.clear();
int mid = n/2;
dfs(1,mid,1);
dfs2(mid+1,1);
lansn();
}

return 0;
}

展开全文
• Dice Game time limit per test 1.0 s memory limit per test 256 MB input standard input output standard output A dice is a small cube, with each side having a different number of spots on it.....
• A dice is a small cube, with each side having a different number of spots on it, ranging from 1 to 6. Each side in the dice has 4 adjacent sides that can be reached by rotating the dice (i.e. the cur...
• Time limit 1000 ms Memory limit 262144 kB ...A dice is a small cube, with each side having a different number of spots on it, ranging from 1 to 6. Each side in the dice has 4 adjacent sides tha...
• A dice is a small cube, with each side having a different number of spots on it, ranging from 1 to 6. Each side in the dice has 4 adjacent sides that can be reached by rotating the dice (i.e. the curr...
• A dice is a small cube, with each side having a different number of spots on it, ranging from 1 to 6. Each side in the dice has 4 adjacent sides that can be reached by rotating the dice (i.e. the cur...
• <div><p>Update check that didn't allow dice images with 0 value</p><p>该提问来源于开源项目：triplea-game/triplea</p></div>
• It is always fun to play with dice, here is one interesting game: You are given n fair dice with 6 faces, the faces does not necessarily have values from 1 to 6 written on them. instead, they can...
• Board GameDice

2019-08-26 21:59:26
hh is a Board Game hobbyist, he often plays Board Game such as Catan, Carcassonne, The Werewolves, A song of ice and fire with friends. To play the games, we need some dices, and these dices are ...
• lab07dice_game

2021-03-14 21:00:19
Rules of game (1) once rolls two dice (2) First roll 2,3,12: LOSE 7,11: WIN others: maked as a “point” (3) Later rolls “point”: WIN 7: LOSE HINT (1)die.py: Class Die Attribute: current
• hh is a Board Game hobbyist, he often plays Board Game such as Catan, Carcassonne, The Werewolves, A song of ice and fire with friends. To play the games, we need some dices, and these dices are ...
• TOJ 3488 GameDice

2014-01-24 17:43:00
描述 In the game of Dungeons ... Dragons, players often roll multi-sided dice to generate random numbers which determine the outcome of actions in the game. These dice come in various flavors and s...
• hh is a Board Game hobbyist, he often plays Board Game such as Catan, Carcassonne, The Werewolves, A song of ice and fire with friends. To play the games, we need some dices, and these dices are ...
• <div><p>Now that #5091 is done I want to discuss the future of dice servers in general. <h3>What we're all agreeing on <p>The PHP code of the dice server is something no one really wants to ...
• <div><p>The two methods are identical so combine them. <h2>Testing <h2>Screens Shots <h2>Additional Notes to Reviewer <h2>Release Note 该提问来源于开源项目&#...triplea-game/triplea</p></div>
• Case Study: A Game of ... Introducing enum Types A popular game of chance is a dice game known as craps, which is played in casinos and back alleys throughout the world. The rules of the game are ...
• <div><p>Remove check that limits aa attack to half of dice sides as it isn't clear as to why that is done. Given that check exists, no existing maps should have a value greater than half so should...
• <div><p>dice.tripleawarclub.org redirects to https, with these updates we would request dice rolls from the https endpoint directly. These updates are based on 's comment in: ...
• RPG dice

2021-01-12 02:11:23
adds rpg dice and makes the game master profession start with them" <h4>Purpose of change <p>Purpose of Change: Now as I didn't fix a bug I don't know if I should use this, but just in ...
• Dice Contest

2017-08-03 06:11:39
The goal of the game is to roll the die from the starting square to the selected target square so that the sum of costs of all moves is minimal. Task Write a program that: reads the description ...
• ve retried in a variety of scenarios, but in any case no matter who initiates combat the game is locked at first red dice throw. I'll try again and add screenshots later if I can. <p>Game Setup:...
• Dice Rolling

2020-12-08 20:41:48
<div><p>The dice rolling mechanics are way off. For example, I had 5 Battleships (hits on 1, 2, 3, and 4) and 14 Fighters (hit on 1, 2, and 3) and only got 5 hits in an attack. I tried the attack ...
• Playing with Dice

2019-05-28 20:47:43
Two players are playing a ... First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers h...
• Chun-Soo is playing a dice stacking game. Six faces of a die are squares of the same size; each face of a die has a number from 1 to 6. But, they are not standard dice because the sum of the nu...
• Just was checking this option throughout as I was getting some cold dice and opponent was rolling a lot of reds. <h3>Instead of this error, what should have happened? <p>Should list something like ...

...