河南省第四届ACM程序设计大赛
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <iostream>
#define INF 32768
#define mod 1000000007
#define ll long long
using namespace std; int Getnum(char s[])
{
int i, sum=; for(i=; s[i]; i++)
sum = sum* + s[i]-''; return sum;
} void Print(int num)
{
num--;
if(num<)
{
printf("%c", num+'A');
return ;
} Print(num/); printf("%c", num%+'A');
} int main()
{
int T;
scanf("%d", &T);
while(T--)
{
char s[]; scanf("%s", s); if(s[]>='' && s[]<='')
{
int num = Getnum(s);
Print(num);
printf("\n");
}
else
{
int sum=; for(int i=; s[i]; i++)
sum = sum* + s[i]-'A'+; printf("%d\n", sum);
}
}
return ;
}
C: 表达式求值
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm> using namespace std;
#define met(a,b) (memset(a,b,sizeof(a)))
const int N=;
#define INF 0x3f3f3f3f char s[N]; int Find3(int x) ///找到当前括号匹配的,
{
int i, sum=; for(i=x; s[i]; i++)
{
if(s[i]=='(')
sum ++;
if(s[i]==',')
{
sum --;
if(sum==)
return i;
}
}
}
int Find4(int x) ///找到,后的第一个)
{
int i; for(i=x; s[i]; i++)
if(s[i]==')')
return i-;
} int Getnum(int L, int R)
{
int i, sum=; for(i=L; i<=R; i++)
sum = sum* + s[i]-'';
return sum;
} int Slove(int x)
{
int L=x+, Index1, Index2, Lsum, Rsum; Index1 = Find3(x);
Index2 = Find4(Index1); if(s[L+]>='' && s[L+]<='')
Lsum = Getnum(L+, Index1-);
else
Lsum = Slove(L+); if(s[Index1+]>='' && s[Index1+]<='')
Rsum = Getnum(Index1+, Index2);
else
Rsum = Slove(Index1+); if(s[x]=='a')
return Lsum+Rsum;
if(s[x+]=='a')
return max(Lsum, Rsum);
if(s[x+]=='i')
return min(Lsum, Rsum);
} int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int ans; scanf("%s", s); ans = Slove(); printf("%d\n", ans);
}
return ;
} /**
22
add(1,2)
max(1,999)
add(min(1,1000),add(100,99))
add(min(1,1000),max(1,add(100,99)))
*/
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm> using namespace std; //这个表达式求值,要先算最小单元的数值,可以采用递归方式 char str[]; //使用全局数据保存字符串
int first;//字符当前位置 int fun() //函数,分析字符
{
int v,n;//保存数字及数字的位数
switch(str[first]) //分析字符串的开头字符
{
case 'm': //有可能是max,min
first+=;//指向括号
if(str[first-]=='i')//对于min
return min(fun(),fun()); //如min(3,5),递归时就会分别返回3和5,然后当成min的参数
else
return max(fun(),fun());
break; case 'a': //是add
first+=;
return fun()+fun(); //如add(3,5),递归时就会返回3和5
break;
case ',': //分隔符
case '(':
case ')':
first++;//跳过不处理
return fun();//继续递归
break;
default: //数字
sscanf(str+first,"%d%n",&v,&n);//从字符str+first开始将数字读入v,数字位数为n
first+=n;//走过数字
return v;
break; } } int main()
{
int n;
scanf("%d",&n);//n组测试数据
while(n--)
{
scanf("%s",str);//字符数据
cout<<fun()<<endl;
first=;//每次测试完要使first归零
} return ;
}
/**
1000
add(1,2)
max(1,999)
add(min(1,1000),add(100,99))
add(min(1,1000),max(1,add(100,99)))
*/
D: 走迷宫
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm> using namespace std;
#define met(a,b) (memset(a,b,sizeof(a)))
const int N=;
#define INF 0x3f3f3f3f int n, flag;
int a[N][N], vis[N][N];
int dir[][]={{,},{,},{-,},{,-}}; void DFS(int x, int y, int Min, int Max)
{
if(x==n && y==n)
{
flag = ;
return ;
}
for(int i=; i<; i++)
{
int nx = x + dir[i][];
int ny = y + dir[i][];
if(nx>= && nx<=n && ny>= && ny<=n && a[nx][ny]>=Min && a[nx][ny]<=Max && !vis[nx][ny])
{
vis[nx][ny] = ;
DFS(nx, ny, Min, Max);
}
if(flag)
return ;
}
} int Slove(int mid, int Min, int Max)
{
int i; for(i=Min; i<=Max-mid; i++)
{
if(a[][]<i || a[][]>i+mid) continue;
if(a[n][n]<i || a[n][n]>i+mid) continue;
flag = ;
met(vis, );
vis[][] = ;
DFS(, , i, i+mid);
if(flag) return ;
}
return ;
} int main()
{
while(scanf("%d", &n)!=EOF)
{
int i, j, Max=-INF, Min=INF; for(i=; i<=n; i++)
for(j=; j<=n; j++)
{
scanf("%d", &a[i][j]);
Max = max(Max, a[i][j]);
Min = min(Min, a[i][j]);
} int L=, R=Max-Min, mid, w, ans=R;
while(L<=R)
{
mid = (L+R)/; w = Slove(mid, Min, Max);
if(w)
{
ans = min(ans, mid);
R = mid-;
}
else L = mid+;
} printf("%d\n", ans);
}
return ;
}
河南省第四届ACM程序设计大赛的更多相关文章
- nyoj 1238 最少换乘 (河南省第八届acm程序设计大赛)
题目1238 题目信息 执行结果 本题排行 pid=1238" style="text-decoration:none; color:rgb(55,119,188)"&g ...
- nyoj 1239 引水project (河南省第八届acm程序设计大赛)
题目1239 pid=1239" style="color:rgb(55,119,188)">题目信息 pid=1239" style="col ...
- nyoj1237 最大岛屿(河南省第八届acm程序设计大赛)
题目1237 pid=1237" style="color:rgb(55,119,188)">题目信息 执行结果 本题排行 讨论区 最大岛屿 时间限制:1000 m ...
- 河南省第五届ACM程序设计大赛
D: 遥 控 器 #include<cstdio> #include<cstring> #include<iostream> #include<algor ...
- 河南省第八届ACM程序设计大赛
A:挑战密室 #include <iostream> #include <cstdio> #include <cstring> #include <algor ...
- 河南省第八届ACM程序设计大赛总结
简单的对这次省赛做个总结:总体来说这个比赛过程中做的还算比较顺利,虽然中间多多少少遇到一些坑,正式比赛开始后,我们就开始找水题,当然了我首先把英文题目翻译了一遍,发现了一道水题,这道题目其实就是判断点 ...
- 西南科技大学第十一届ACM程序设计大赛发言稿
西南科技大学第十一届ACM程序设计大赛发言稿 各位老师.志愿者及参赛选手: 大家好,我是来自计科学院卓软1301的哈特13,很荣幸今天能站在这里代表参赛选手发言. 回想起来,我参加ACM比赛已经快两年 ...
- 第13届 广东工业大学ACM程序设计大赛 C题 平分游戏
第13届 广东工业大学ACM程序设计大赛 C题 平分游戏 题目描述 转眼间又过了一年,又有一届的师兄师姐要毕业了. 有些师兄师姐就去了景驰科技实习. 在景驰,员工是他们最宝贵的财富.只有把每一个人 ...
- 河南省第四届ACM省赛(T3) 表达式求值
表达式求值 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Dr.Kong设计的机器人卡多掌握了加减法运算以后,最近又学会了一些简单的函数求值,比如,它知道函数min ...
随机推荐
- Endless Sky源码学习笔记-5
游戏启动后的UI划分为三个区域,左侧滚动显示credits等信息以及偏好设置和退出按钮,中间显示载入动画,右侧显示玩家信息以及载入存档按钮,调用void MenuPanel::Draw()实现.首先画 ...
- KeepAlived主备模型高可用LVS
部署前准备: 1.至少4台主机:两个Director(HA1,HA2),两个Real Server(RS1,RS2) 2.Director之间时间必须同步,且关闭各主机的防火墙和Selinux 3.出 ...
- 技术英文单词贴--I
I increase 增加,增大 individual 个人的,个别的 instead 代替 integer 整数,整形
- command line
command line terminal vim 编辑工具 vim 编辑命令 j 光标上移 k 光标下移 l 光标左移 h 光标右移 x / dd 删除一行 v 多行模式 :w 保存 :q 不保存退 ...
- aspnet超级链接 传递 当前页面 textbox值
一共有两个窗体. 第一个窗体A传参到窗体B A的参数是A窗体的textbox 窗体A代码 <html xmlns="http://www.w3.org/1999/xhtml" ...
- POJ 2135 Farm Tour 最小费用流
两条路不能有重边,既每条边的容量是1.求流量为2的最小费用即可. //#pragma comment(linker, "/STACK:1024000000,1024000000") ...
- DLL强名称引用问题
为没有源码的DLL文件添加强名称 如果项目中引用了其他没有源码的dll文件,并且此dll文件是没有强名称的程序集,则编译时会出现类似 "Assembly generation failed ...
- Mongodb无法访问28107的问题
解压mongodb文件后,放到指定文件,最好别有空格.汉字之类的文件中 此时在mongodb文件夹下,建立一个 db 文件夹,此时执行启动命令,默认27017端口号可以打开,但是28017端口无法打开 ...
- ubuntu下安装wordpress
网上大多都是说放在var/www下面 实际上新版的ubuntu默认放在 var/www/html 下面 当然这个配置是可以修改的
- Tier和RBD Cache的区别
相同点 缓存 数据不会持久保存在ssd或者内存:预读回写直写 都需要解决缓存数据和磁盘数据不一致和“内存页”置换的问题. 差异点 缓存的位置不同,tier是rados层在osd端进行数据缓存,也就是说 ...