当前位置: 首页 > 工具软件 > Bones > 使用案例 >

P2911 [USACO08OCT]Bovine Bones G(期望)

裴宜春
2023-12-01

P2911 [USACO08OCT]Bovine Bones G

解题思路:期望入门题。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lf;
typedef unsigned long long ull;
typedef pair<ll,int>P;
const int inf = 0x7f7f7f7f;
const ll INF = 1e16;
const int N = 1e5+10;
const ull base = 131;
const ll mod =  1e9+7;
const double PI = acos(-1.0);
const double eps = 1e-4;

inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
inline string readstring(){string str;char s=getchar();while(s==' '||s=='\n'||s=='\r'){s=getchar();}while(s!=' '&&s!='\n'&&s!='\r'){str+=s;s=getchar();}return str;}
int random(int n){return (int)(rand()*rand())%n;}
void writestring(string s){int n = s.size();for(int i = 0;i < n;i++){printf("%c",s[i]);}}
ll fast_power(ll a,ll p){
    ll ans = 1;
    while(p){
        if(p&1) ans = (ans*a)%mod;
        p >>= 1;
        a = (a*a)%mod;
    }
    return ans;
}

map<int,int>vis;

int main(){
    //srand((unsigned)time(NULL));
    //freopen(  "out.txt","w",stdout);
    int a = read(),b = read(),c = read();
    for(int i = 1;i <= a;i++){
        for(int j = 1;j <= b;j++){
            for(int k = 1;k <= c;k++){
                vis[i+j+k]++;
            }
        }
    }
    int sum = 0,ans = 0;
    for(auto it = vis.begin();it != vis.end();it++){
        if(it->second > sum){
            sum = it->second;
            ans = it->first;
        }
    }
    cout<<ans<<endl;
    return 0;
}

 类似资料: