https://icpc.baylor.edu/regionals/finder/north-america-qualifier-2015

一个人打。。。。

B

概率问题公式见代码

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long
void fre() {
freopen("in.txt","r",stdin);
} inline int r(){
int x=,f=;char ch=getchar();
while(ch>''||ch<''){if(ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} int countt;
int comb1(int m,int k)
{
int i;
for (i=m;i>=k;i--)
{
if (k>)
{
comb1(i-,k-);
}
else
{
countt++;
}
}
return countt;
} int main(){
// fre();
int T;
int R,s,x,y,w;
T=r();
while(T--){
double p1=0.0;
int num;
cin>>R>>s>>x>>y>>w;
double p=(s-R+)*1.0/s;
double ans=0.0;
for(int i=x;i<=y;i++){
int c=y-i;
p1=1.0;
double p2=1.0-p;
while(c--){
p1*=p2;
}
int cc=i;
double P=1.0;
for(int j=;j<=i;j++){
P*=p;
}
// cout<<i<<" "<<P<<endl;
countt=;
num=comb1(y,i);
// cout<<P<<" "<<p1<<" "<<num<<endl;
ans+=P*p1*num;
}
// cout<<ans<<endl;
if(ans*w>)
printf("yes\n");
else
printf("no\n");
}
return ;
}

F

水题

输出字符串中缺少的字母

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long
void fre(){freopen("in.txt","r",stdin); }
// inline int r(){
// int x=0,f=1;char ch=getchar();
// while(ch>'9'||ch<'0'){if(ch=='-') f=-1;ch=getchar();}
// while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
// return x*f;
// }
int a[];
char ans[];
int main()
{ int T;
scanf("%d",&T);
getchar();
while(T--)
{
clc(a,);
clc(ans,);
string s;
getline(cin,s);
for(int i = ; i < s.length(); i ++){
if(s[i] >= 'a' && s[i] <= 'z')
a[s[i] - 'a'] ++;
if(s[i] >= 'A' && s[i] <= 'Z')
a[s[i] - 'A'] ++;
}
int k = ;
for(int i = ; i < ; i ++){
if(!a[i]){
ans[k++] = i + 'a';
}
}
if(k ==) {
printf("pangram\n");
}
else{
printf("missing ");
for(int i = ; i< k; i ++){
printf("%c",ans[i]);
}
printf("\n");
}
}
return ;
}

G

过河的经典问题

多个人过河每次船上必须有一人问最短时间

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long
void fre() {
freopen("in.txt","r",stdin);
} inline int r(){
int x=,f=;char ch=getchar();
while(ch>''||ch<''){if(ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} int TravelBridge(std::vector<int> times)
{
size_t length = times.size();
if(length <= )
return times[length-];
else if(length == )
{
return times[] + times[] + times[];
}
else
{
int totaltime = ;
int a = times[];
int b = times[];
int z = times[length-];
int y = times[length-];
if(b* < a + y)
{
times.erase(times.end()-);
times.erase(times.end()-);
totaltime += b + a + z + b + TravelBridge(times);
}
else
{
times.erase(times.end()-);
totaltime += z + a + TravelBridge(times);
}
return totaltime;
}
} int main(){
int n;
n=r();
vector<int> v;
for(int i=;i<n;i++){
int x;
x=r();
v.push_back(x);
}
sort(v.begin(),v.end());
int ans=TravelBridge(v);
printf("%d\n",ans);
return ;
}

H

水题

旋转矩阵再输出

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long
void fre() {
freopen("in.txt","r",stdin);
} inline int r(){
int x=,f=;char ch=getchar();
while(ch>''||ch<''){if(ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} char s[];
char a[][];
int main() {
// fre();
int T;
T=r();
// getchar();
while(T--) {
scanf("%s",s);
int len = strlen(s);
int q = ;
for(; ; q ++) {
if(q * q >= len) {
break;
}
}
// cout<<s[0]<<endl;
int pos;
for(int i = ; i < q; i ++) {
for(int j = ; j < q ; j ++) {
pos = i * q + j;
if(pos >= len) {
a[i][j] = '*';
} else {
a[i][j] = s[pos];
}
}
}
// printf("%c\n",a[0][0]);
// for(int i=0;i<q;i++){
// for(int j=0;j<q;j++){
// printf("%c ",a[i][j]);
// }
// printf("\n");
// }
for(int j = ; j < q ; j ++) {
for(int i = q - ; i >= ; i --) {
if(a[i][j] != '*')
printf("%c",a[i][j]);
}
}
printf("\n");
}
return ;
}

J

把单词映射成数字

从起点到终点搜索

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <list>
#include <map>
#include <stack>
#include <vector>
#include <cstring>
#include <sstream>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long
void fre() {
freopen("in.txt","r",stdin);
}
inline int r() {
int x=,f=;
char ch=getchar();
while(ch>''||ch<'') {
if(ch=='-') f=-;
ch=getchar();
}
while(ch>=''&&ch<='') {
x=x*+ch-'';
ch=getchar();
}
return x*f;
} int a[][] = {};
int p[];
string s[];
int n;
int ans[];
bool idx[] = {false};
int num = ;
map<string,int> mapp; void dfs(int u,int v) {
if(u == v)
return;
idx[u] = true;
for(int i = ; i <= num; i ++) {
if(a[u][i] == && idx[i] == false) {
p[i] =u;
dfs(i,v);
}
}
idx[u] = false;
} int main() {
clc(a,);
mapp.clear();
n=r();
// getchar();
string line,x;
string s1,s2;
int k = ;
int t;
bool flag = false;
int u,v;
for(int i =; i < n; i ++) {
getline(cin,line);
stringstream ss(line);
ss>>x;
if(mapp[x] == ) {
mapp[x] = num;
s[num] = x;
num ++;
}
u = mapp[x];
while(ss >> x) {
if(mapp[x] == ) {
mapp[x] = num;
s[num] = x;
num ++;
}
v = mapp[x];
a[u][v] = ;
a[v][u] = ;
}
}
cin>>s1>>s2;
if(mapp[s1] == ) {
mapp[s1] = num;
num ++;
}
u= mapp[s1];
if(mapp[s2] == ) {
mapp[s2] = num;
num ++;
}
v = mapp[s2];
dfs(u,v);
p[u] = -;
t = v;
while(t != -) {
ans[k ++] = t;
if(t == ) {
flag = true;
break;
}
t = p[t];
}
if(flag == true) {
printf("no route found\n");
return ;
}
for(int i = k - ; i >= ; i --) {
cout<<s[ans[i]]<<" ";
}
cout<<s[v]<<endl; }

一个人打也挺好玩的

North America Qualifier (2015)的更多相关文章

  1. East Central North America Region 2015

    E 每过一秒,当前点会把它的值传递给所有相邻点,问t时刻该图的值 #include <iostream> #include <cstdio> #include <algo ...

  2. 2019 ACM/ICPC North America Qualifier G.Research Productivity Index(概率期望dp)

    https://open.kattis.com/problems/researchproductivityindex 这道题是考场上没写出来的一道题,今年看看感觉简单到不像话,当时自己对于dp没有什么 ...

  3. 2015 UESTC Winter Training #6【Regionals 2010 >> North America - Rocky Mountain】

    2015 UESTC Winter Training #6 Regionals 2010 >> North America - Rocky Mountain A - Parenthesis ...

  4. Regionals 2013 :: North America - Southeast USA

    Regionals 2013 :: North America - Southeast USA It Takes a Village As a Sociologist, you are studyin ...

  5. MPI Maelstrom(East Central North America 1996)(poj1502)

    MPI Maelstrom 总时间限制:  1000ms 内存限制:  65536kB 描述 BIT has recently taken delivery of their new supercom ...

  6. poj 2732 Countdown(East Central North America 2005)

    题意:建一个家庭树,找出有第d代子孙的名字,按照要求的第d代子孙的数从大到小输出三个人名,如果有一样大小子孙数的,就按字母序从小到大将同等大小的都输出,如果小于三个人的就全输出. 题目链接:http: ...

  7. [New Portal]Windows Azure Cloud Service (34) TechEd 2013 North America关于Azure的最新消息

    <Windows Azure Platform 系列文章目录> 话说TechEd 2013 US上个月3-6日在美国举办了,笔者的文章又有点姗姗来迟了. 需要了解相关视频的网友,请浏览ht ...

  8. 组队练习赛(Regionals 2012, North America - East Central NA)

    A.Babs' Box Boutique 给定n个盒子,每个盒子都有长宽高(任意两个盒子长宽高不完全相同),现在选盒子的任意两面,要求x1 <= x2 && y1 <= y ...

  9. Regionals 2012, North America - Greater NY 解题报告

    这套题..除了几何的都出了 完全没时间学几何.杯具 A,B,J 水题不解释 C.Pen Counts 这题的话 写几个不等式限制边得范围就行了 然后枚举最小边 D.Maximum Random Wal ...

随机推荐

  1. mybatis include标签

    使用mybatis 的include标签达到SQL片段达到代码复用的目的 示例: xml文件 <sql id="paysql"> payid,p.oid,p.bdate ...

  2. [转载]自定义ASP.NET MVC Html辅助方法 TagBuilder

    在ASP.NET MVC中,Html辅助方法给我们程序员带来很多方便,其重要性也就不言自明.有时候,我们不想重复地写一些HTML代码,或者MS没有提供我们想要的那个HTML标签的Html辅助方法,那么 ...

  3. how to make form:checkboxes in JSP

    retransmitTable.jsp file: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix=&qu ...

  4. 【leetcode】Palindrome Number (easy)

    Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...

  5. codeforces #313 div1 C

    同BZOJ 3782 上学路线 QAQ 还比那个简单一点 把坐标(1,1)-(n,m)平移成(0,0)-(n-1,m-1) 设dp[i]表示从(1,1)出发第一次经过障碍且到达第i个障碍的方案数 首先 ...

  6. 删除appcompat_v7会出很多错误

    创建工程的时候会出现appcompat_v7这个文件夹 手贱删除后,发现出错了 说明test项目是依赖于appcompat_v7包的,所以这个appcompat_v7包是不能被删除的. appcomp ...

  7. nchar 和 nvarchar

    字符数据类型(nchar 长度固定,nvarchar 长度可变)和 Unicode 数据使用 UNICODE UCS-2 字符集. nchar [ ( n ) ] n 个字符的固定长度的 Unicod ...

  8. SRM 587 DIV1

    要掉到DVI2了..好不容这次的250那么简单,500的题知道怎么做,可惜没调出来500. 250的题很简单,从第1步到第N步,每次要么不做,要么走i步,且X不能走,问说最远走多远. #include ...

  9. P44、面试题4:替换空格

    题目:请实现一个函数,把字符串中的每个空格替换成“%20”.例如输入“We are happy.”,则输出“We%20are%20happy.”. 如果用java string类中提供的replace ...

  10. 通过dbms_xplan.display_cursor识别低效的执行计划

    dbms_xplan.display_cursor定义: function display_cursor(sql_id           varchar2 default  null,        ...