跳过正文
  1. Posts/

bzoj 1599: [Usaco2008 Oct]笨重的石子 (暴力)

·2 分钟
目录

1599: [Usaco2008 Oct]笨重的石子
#

Time Limit: 10 Sec  Memory Limit: 162 MB Submit: 886  Solved: 614 [Submit][Status][Discuss]

Description
#

贝西喜欢棋盘游戏和角色扮演类游戏所以她说服Farmer John把她带到玩具店,在那里,她购买了三个不同的骰子,这三个质量均匀的骰子,分别有S1,S2,S3个面。(2 <= S1 <= 20; 2 <= S2 <= 20; 2 <= S3 <= 40). 贝西掷啊掷啊掷啊,想要知道出现几率最大的和是多少。 问题给出三个骰子的面数,让你求出出现几率最大的和是多少。如果有很多种和出现的几率相同,那么就输出小的那一个。

Input
#

*第一行:三个由空格隔开的整数:s1,s2,s3

Output
#

*第一行:所要求的解

Sample Input
#

3 2 3

Sample Output
#

5

输出详解:

这里是所有可能的情况.

1 1 1 -> 3 1 2 1 -> 4 2 1 1 -> 4 2 2 1 -> 5 3 1 1 -> 5 3 2 1 -> 6

1 1 2 -> 4 1 2 2 -> 5 2 1 2 -> 5 2 2 2 -> 6 3 1 2 -> 6 3 2 2 -> 7

1 1 3 -> 5 1 2 3 -> 6 2 1 3 -> 6 2 2 3 -> 7 3 1 3 -> 7 3 2 3 -> 8

5和6出现的几率都是最大的,所以输出5.

暴力。。。

 1/* ***********************************************
 2Author :111qqz
 3Created Time :2016年03月31日 星期四 21时13分18秒
 4File Name :code/bzoj/1599.cpp
 5************************************************ */
 6
 7#include <cstdio>
 8#include <cstring>
 9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33int s1,s2,s3;
34double a[100];
35int main()
36{
37	#ifndef  ONLINE_JUDGE
38	freopen("code/in.txt","r",stdin);
39  #endif
40	cin>>s1>>s2>>s3;
41	ms(a,0);
42	for ( int i = 1 ;i  <= s1 ; i++)
43	{
44	    for ( int j = 1 ; j <= s2 ; j++)
45	    {
46		for ( int k = 1 ; k <= s3 ; k++)
47		{
48		    a[i+j+k] += 1.0/s1+1.0/s2+1.0/s3;
49		}
50	    }
51	}
52
53	double p = -1;
54	int ans ;
55	for ( int i = 3 ; i <= s1+s2+s3 ; i++)
56	{
57	    if (a[i]>p)
58	    {
59		p = a[i];
60		ans = i ;
61	    }
62	}
63
64	cout<<ans<<endl;
65
66  #ifndef ONLINE_JUDGE
67  fclose(stdin);
68  #endif
69    return 0;
70}

相关文章

codeforces #346 div 2 C. Tanya and Toys (暴力乱搞)

·2 分钟
题目链接 题意:有1E9个礼物,第i个礼物价钱是i,然后现在已经有n个不重复的礼物,a[i],m元钱,想尽可能多得买不同种类的礼物,还能买多少个。 思路:先不考虑已经买的,从1连续买到k,然后考虑子啊这个区间内已经买的,等于实际上没有花钱。 反正就是暴力搞啊搞啊。。我也不知道怎么搞。。 结果最后。。方案数为0的时候。。。最后一个答案我是单独输出的。。忘了判断了。。。所以会输出两个0.宝宝心里苦啊。。。。。。。。

codeforces 334 B. Eight Point Sets (暴力)

·1 分钟
题目链接 题意:给出8个点,问能否构成一个8元素集合,使得x1/* *********************************************** Author :111qqz Created Time :2016年03月31日 星期四 13时39分27秒 File Name :code/cf/problem/334B.cpp ************************************************ */

codeforces croc2016 A. Amity Assessment (暴力)

·1 分钟
题目链接 题意:2×2的格子,有三个位置分别放”A“ “B” “C” ,一个位置为空。只有和空位相邻位置上的字母能移动到空位。没有其他移动规则。现在给出两个状态。问能否互相转化。 思路: 貌似可以dfs…?但是一共才2*2,可以直接暴力枚举。 手写一种变换最多能有12种。