2016 ICPC 青岛站(ICPC补题计划)(概率期望,模拟)

A.Relic Discovery(签到题)
题目传送
AC代码

#include 
inline long long read(){char c = getchar();long long x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 2e5 + 10;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const int mod = 1e9+7;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);
    int t;
    cin >> t;
    while(t--)
    {
        ll n,sum = 0;
        cin >> n;
        while(n--)
        {
            ll a,b;
            cin >> a >> b;
            sum += (a*b);
        }
        cout << sum << endl;
    }
}

B.Pocket Cube(模拟)
题目传送
题意:
给你一个二阶魔方,判断是否能在最多一次扭转的情况下,使得魔方还原。

思路:
强行模拟,因为魔方的扭转情况只有6种扭转情况,然后枚举模拟即可,代码就不写了。。。。好吧我懒

C. Pocky(概率期望)
这是我做的概率问题的第一个题,没有什么思路。。。
题目传送
别人的题解

不过这里可以直接猜公式:ln 2 = 0.693147,
然后再观察下,会发现公式为1 + log(l/d)。//默认log的底数为自然数对数底数
exp(1)为自然数对数底数

AC代码

#include 
inline long long read(){char c = getchar();long long x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 2e5 + 10;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const int mod = 1e9+7;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);
    int t;
    cin >> t;
    while(t--)
    {
        double l,d;
        cin >> l >> d;
        if(l <= d)
            cout << "0.000000" << endl;
        else
            cout << fixed << setprecision(6) << log((l/d)) + 1.0 << endl;
    }
}

你可能感兴趣的:(ccpc补题计划)