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的更多相关文章

  1. 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_{ ...

  2. gym101532 2017 JUST Programming Contest 4.0

    台州学院ICPC赛前训练5 人生第一次ak,而且ak得还蛮快的,感谢队友带我飞 A 直接用claris的模板啊,他模板确实比较强大,其实就是因为更新的很快 #include<bits/stdc+ ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 2017 JUST Programming Contest 2.0

    B. So You Think You Can Count? 设dp[i]表示以i为结尾的方案数,每个位置最多往前扫10位 #include<bits/stdc++.h> using na ...

随机推荐

  1. karaf增加自己定义log4j的配置

    配置文件: karaf_home/etc/org.ops4j.pax.logging.cfg 增加配置: ### direct log messages to stdout ### log4j.app ...

  2. Zend Studio如何调试?

    1.安装Zend Studio之前,本机已安装Apache2.如果使用Apache2作为服务器 Window-Preferences-Php-Php Servers 配置好 URL和Server Ro ...

  3. 2016/1/20 笔记 1, 包 引入 static 已经补充到类里 2,继承

    继承  1,关键字 extends       2,子类自动继承父类非私有的属性和方法 也叫成员变量 成员方法       3,super代表的是父类 调用父类的方法 默认在构造函数中生成      ...

  4. String,StringBuffer,StringBuilder三者有什么异同?

    相同点: 1.三者都是Java平台提供的三种类型得到字符串,它们可以储存和操作字符串. 不同点: 1.String是final修饰的,也就意味着String引用的字符串内容是不能被改变的.而Strin ...

  5. ZOJ Design the city LCA转RMQ

    Design the city Time Limit: 1 Second      Memory Limit: 32768 KB Cerror is the mayor of city HangZho ...

  6. CPU上电时序详细分析

    首先是RTC电源,这部分电力是永远不关闭的,除非电池(纽扣电池)没电并且没接任何外部电源(比如电池和电源适配器). RTC用以保持机器内部时钟的运转和保证CMOS配置信息在断电的情况下不丢失:其次,在 ...

  7. 经典的printk 写法

    经典的printk 写法: printk("[lynn--%s@%d]: addr:0x%x  \n",__func__,__LINE__,obj->client->a ...

  8. Error处理: android.media.MediaRecorder.start(Native Method) 报错:start failed: -19【转】

    本文转载自:http://blog.csdn.net/netwalk/article/details/17686993 Error处理: android.media.MediaRecorder.sta ...

  9. mysql与mongoDB的特点和优劣

    首先分析下mysql与mongoDB的特点和优劣 从图中分析: 再来分析下应用场景: a.如果需要将mongodb作为后端db来代替mysql使用,即这里mysql与mongodb 属于平行级别,那么 ...

  10. luence全文检索(简介)

    刚开始做全文检索也是找了很多资料但是网上的都不是很齐全luence是个很不多的工具 Lucene4.0的官网文档:http://lucene.apache.org/core/4_0_0/core/ov ...