gym101343 2017 JUST Programming Contest 2.0
A.On The Way to Lucky Plaza (数论)
题意:m个店 每个店可以买一个小球的概率为p
求恰好在第m个店买到k个小球的概率
题解:求在前m-1个店买k-1个球再*p就好了 最开始没太懂输出什么意思
其实就是p*q的逆元的意思 因为概率是三位小数于是对他*1000*1000的逆元处理
还要加个eps 因为0.005浮点数由于不确定性可能存的0.0050001或者0.00499999
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = ; ll ny[]; ll pow_mod(ll x, ll y)
{
ll res = ;
while(y)
{
if(y & ) res = res * x % mod;
x = x * x % mod;
y >>= ;
}
return res % mod;
} int main()
{
ll n, m, k;
scanf("%lld%lld%lld", &m, &n, &k);
for(ll i = ; i <= ; i++) ny[i] = pow_mod(i, mod - 2LL); double pp;
scanf("%lf", &pp);
ll p = * pp + 1e-; ll ans = ;
for(int i = ; i <= k - ; i++) ans = ans * ny[i] % mod;
for(ll i = ; i <= k - ; i++) ans = ans * (n - i) % mod;
for(int i = ; i <= k; i++) ans = ans * p % mod;
for(int i = ; i <= n - k; i++) ans = ans * ( - p) % mod;
for(int i = ; i <= n; i++) ans = ans * ny[] % mod;
printf("%lld\n", ans);
return ;
}
B.So You Think You Can Count?(水DP)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = ; char s[];
int vis[];
ll dp[]; int main()
{
int n;
scanf("%d", &n);
scanf("%s", s + );
dp[] = ; for(int i = ; i <= n; i++)
{
memset(vis, , sizeof(vis)); for(int j = i; j >= ; j--)
{
if(vis[s[j] - '']) break;
else
{
vis[s[j] - ''] = ;
dp[i] = (dp[i] + dp[j - ]) % mod;
}
}
}
printf("%lld\n", dp[n]);
return ;
}
C.MRT Map (最短路) 不会写最短路 学姐写的
D.Husam's Bug (水题)
E.Abdalrahman Ali Bugs (水题)
F.Certifications (水题)
G.In the Chairman's office (水题)
H.Give Me This Pizza
题意:给一个数组 求每个数右边第一个比他大的数是谁
题解:ai才不到50 从后往前暴力即可 存每个数最后出现的位置
#include <bits/stdc++.h>
using namespace std; int vis[];
int q[];
int ans[]; int main()
{
int n;
scanf("%d", &n);
for(int i = ; i <= n; i++) scanf("%d", &q[i]); for(int i = ; i <= ; i++) vis[i] = ;
for(int i = ; i <= n; i++) ans[i] = ; for(int i = n; i >= ; i--)
{
vis[q[i]] = i;
int f = -;
for(int j = q[i] + ; j <= ; j++)
{
if(vis[j] < ans[i])
{
ans[i] = vis[j];
f = j;
}
}
ans[i] = f;
}
for(int i = ; i <= n; i++)
{
if(i != n) printf("%d ", ans[i]);
else printf("%d\n", ans[i]);
}
return ;
}
I.Husam and the Broken Present 1 (水题)
J.Husam and the Broken Present 2 (状压DP) 题解戳
K.Counting Time (模拟)
题意:给一个九宫格的初始状态 填完这个九宫格使得每个数字x能跳到x+1的方案有多少种
能跳到的区域为八连通 且x只能跳到x+1
题解:模拟
#include <bits/stdc++.h>
using namespace std; int nx[];
int ny[];
int vis[];
char tu[][];
int dx[];
int dy[];
int q[] = {, , , , , , , , , }; int ans;
bool check()
{
dx[q[]] = dx[q[]] = dx[q[]] = ;
dx[q[]] = dx[q[]] = dx[q[]] = ;
dx[q[]] = dx[q[]] = dx[q[]] = ;
dy[q[]] = dy[q[]] = dy[q[]] = ;
dy[q[]] = dy[q[]] = dy[q[]] = ;
dy[q[]] = dy[q[]] = dy[q[]] = ; for(int i = ; i <= ; i++)
if(vis[i])
{
if(dx[i] == nx[i] && dy[i] == ny[i]) continue;
else return false;
} for(int i = ; i <= ; i++)
{
if(abs(dx[i] - dx[i - ]) <= && abs(dy[i] - dy[i - ]) <= ) continue;
else return false;
}
return true;
} int main()
{
ans = ;
for(int i = ; i <= ; i++) scanf("%s", tu[i] + );
for(int i = ; i <= ; i++)
for(int j = ; j <= ; j++)
{
if(tu[i][j]!= '')
{
int c = tu[i][j] - '';
vis[c] = ;
nx[c] = i;
ny[c] = j;
}
} ans += check();
while(next_permutation(q + , q + )) ans += check();
printf("%d\n", ans);
return ;
}
gym101343 2017 JUST Programming Contest 2.0的更多相关文章
- 2017 JUST Programming Contest 2.0 题解
[题目链接] A - On The Way to Lucky Plaza 首先,$n>m$或$k>m$或$k>n$就无解. 设$p = \frac{A}{B}$,$ans = C_{ ...
- gym101532 2017 JUST Programming Contest 4.0
台州学院ICPC赛前训练5 人生第一次ak,而且ak得还蛮快的,感谢队友带我飞 A 直接用claris的模板啊,他模板确实比较强大,其实就是因为更新的很快 #include<bits/stdc+ ...
- 2017 JUST Programming Contest 3.0 B. Linear Algebra Test
B. Linear Algebra Test time limit per test 3.0 s memory limit per test 256 MB input standard input o ...
- 2017 JUST Programming Contest 3.0 I. Move Between Numbers
I. Move Between Numbers time limit per test 2.0 s memory limit per test 256 MB input standard input ...
- 2017 JUST Programming Contest 3.0 D. Dice Game
D. Dice Game time limit per test 1.0 s memory limit per test 256 MB input standard input output stan ...
- 2017 JUST Programming Contest 3.0 H. Eyad and Math
H. Eyad and Math time limit per test 2.0 s memory limit per test 256 MB input standard input output ...
- 2017 JUST Programming Contest 3.0 K. Malek and Summer Semester
K. Malek and Summer Semester time limit per test 1.0 s memory limit per test 256 MB input standard i ...
- 2017 JUST Programming Contest 3.0 E. The Architect Omar
E. The Architect Omar time limit per test 1.0 s memory limit per test 256 MB input standard input ou ...
- 2017 JUST Programming Contest 2.0
B. So You Think You Can Count? 设dp[i]表示以i为结尾的方案数,每个位置最多往前扫10位 #include<bits/stdc++.h> using na ...
随机推荐
- YTU 2543: 数字整除
2543: 数字整除 时间限制: 1 Sec 内存限制: 128 MB 提交: 33 解决: 8 题目描述 定理:把一个至少两位的正整数的个位数字去掉,再从余下的数中减去个位数的5倍.当且仅当差是 ...
- 学习MAP 地图好地址
http://www.cnblogs.com/beniao/archive/2010/01/13/1646446.html Bēniaǒ成长笔记在IT江湖里我不是一名老手,我只是一名普通的程序员,愿意 ...
- P2465 [SDOI2008]山贼集团 dp
这个题是一道树形dp+状压dp二合一,先预处理每种组合会有什么额外的费用,然后在树上dp就行了. 题干: 题目描述 某山贼集团在绿荫村拥有强大的势力,整个绿荫村由N个连通的小村落组成,并且保证对于每两 ...
- dubbo作者讲编码原则
刚看到梁飞谈到dubbo为保证代码质量开发人员必须要注意的,其实也是开发人员应该做的. 1. 防止空指针和下标越界 这是我最不喜欢看到的异常,尤其在核心框架中,我更愿看到信息详细的参数不合法异常, 这 ...
- 洛谷P1850 [noip2016]换教室——期望DP
题目:https://www.luogu.org/problemnew/show/P1850 注释掉了一堆愚蠢,自己还是太嫩了... 首先要注意选或不选是取 min 而不是 /2 ,因为这里的选或不选 ...
- bzoj [JSOI2010]Group 部落划分 Group【二分+并查集】
我是zz吗这么简单都写错-- 一眼二分,然后判断的话是枚举点,然后计算这个点到已有联通块的最小距离,如果这个点到一些联通块的距离小于当前二分的val,则把这些联通块合并起来,这里用并查集维护,最后看这 ...
- 洛谷 P2365 任务安排【dp】
其实是可以斜率优化的但是没啥必要 设st为花费时间的前缀和,sf为Fi的前缀和,f[i]为分组到i的最小花费 然后枚举j转移,考虑每次转移都是把j到i分为一组这样意味着j及之后的都要增加s的时间,同时 ...
- P4556 [Vani有约会]雨天的尾巴(线段树合并)
传送门 一道线段树合并 首先不难看出树上差分 我们把每一次修改拆成四个,在\(u,v\)分别放上一个,在\(lca\)和\(fa[lca]\)各减去一个,那么只要统计一下子树里的总数即可 然而问题就在 ...
- linux Java环境变了配置
1. sudo /etc/profile 2.安装截图配置 输入javac 进行验证
- D. Vasya And The Matrix(Educational Codeforces Round 48)
D. Vasya And The Matrix time limit per test2 seconds memory limit per test256 megabytes inputstandar ...