A:

B:按题意直接暴力找符合题意的数的个数

#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1.0e-6
#define PI acos(-1.0)
#define INF 3000000000
#define MOD 1000000009
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
int num[][];//+ 1 - 2 * 3 / 4
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int n;
string a;
int ans=;
cin >> n;
int now;
for(int i=;i<=n;i++)
{
cin >> a >> now;
num[i][]=now;
if(a[]=='A')
num[i][]=;
if(a[]=='S')
num[i][]=;
if(a[]=='M')
num[i][]=;
if(a[]=='D')
num[i][]=;
}
for(int i=;i<=;i++)
{
int cur=i;
for(int j=;j<=n;j++)
{
if(num[j][]==)
{
cur+=num[j][];
}
if(num[j][]==)
{
cur-=num[j][];
if(cur<)
{
ans++;
break;
}
}
if(num[j][]==)
{
cur*=num[j][];
}
if(num[j][]==)
{
if(cur%num[j][]!=)
{
ans++;
break;
}
else
cur/=num[j][];
}
}
}
cout<<ans<<endl;
return ;
}

C:水

D:s[i][j]可以向四个方向跳s[i][j]个格子 问能不能从左上角跳到右下角 BFS

#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1.0e-6
#define PI acos(-1.0)
#define INF 3000000000
#define MOD 1000000009
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
int dir[][];
int m,n;
char s1[][];
int a[][];
int ans[][];
int flag=;
pair<int,int> now;
queue<pair<int,int> > que;
void bfs()
{
for(int i=;i<=;i++)
for(int j=;j<=;j++)
ans[i][j]=2e9;
ans[][]=;
int dx,dy;
while(!que.empty())
{
now=que.front();
que.pop();
int f=now.first;
int s=now.second;
int j=a[f][s];
for(int i=;i<;i++)
{
dx=f+j*dir[i][];
dy=s+dir[i][]*j;
if(dx>=&&dx<=m&&dy>=&&dy<=n&&ans[dx][dy]>ans[f][s]+)
{
ans[dx][dy]=ans[f][s]+;
now.first=dx,now.second=dy;
que.push(now);
}
}
}
}
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
cin >> m >> n;
dir[][]=-,dir[][]=;
dir[][]=,dir[][]=;
dir[][]=,dir[][]=;
dir[][]=,dir[][]=-;
for(int i=;i<=m;i++)
{
scanf("%s",s1[i]+);
for(int j=;j<=n;j++)
a[i][j]=s1[i][j]-'';
}
/*for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
printf("%d",a[i][j]);
cout<<endl;
}*/
//TS;
now.first=now.second=;
que.push(now);
bfs();
//TS;
if(ans[m][n]==2e9)
cout<<"IMPOSSIBLE"<<endl;
else
cout<<ans[m][n]<<endl;
return ;
}

E:水

F:水

G:水

H:加权区间调度问题 瞎DP

#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1.0e-6
#define PI acos(-1.0)
#define INF 3000000000
#define MOD 1000000009
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
struct wave
{
ll start;
ll w;
ll t;
ll end;
}now[];
bool cmp(wave a,wave b)
{
return a.start>b.start;
}
ll dp[];
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int n;
ll maxn=;
cin >> n;
for(int i=;i<=n;i++)
{
int t;
scanf("%d %d %d",&now[i].start,&now[i].w,&now[i].t);
now[i].end=now[i].t+now[i].start;
maxn=max(maxn,now[i].end);
}
sort(now+,now++n,cmp);
int pop=;
for(int i=;i>=;i--)
{
if(i==now[pop].start)
{
if(i+now[pop].t>)
dp[i]=max(dp[i+],now[pop].w);
else
dp[i]=max(dp[i+],dp[i+now[pop].t]+now[pop].w);
pop++;
}
else
dp[i]=dp[i+];
}
cout<<dp[]<<endl;
return ;
}

J:每个格子的值为其为中心九宫格之和 问最终的值 其实一起都要除九的话就不用除了

#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1.0e-6
#define PI acos(-1.0)
#define INF 3000000000
#define MOD 1000000009
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
int now[][];
int doit[][];
set<int> ans;
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int m,n,time;
cin >> m >> n >> time;
for(int i=;i<n;i++)
for(int j=;j<m;j++)
scanf("%d",&now[i][j]);
while(time--)
{
mem(doit,);
for(int i=;i<n;i++)
{
for(int j=;j<m;j++)
{ for(int x=-;x<=;x++)
{
for(int y=-;y<=;y++)
{
int dx=(n+i+x)%n;
int dy=(m+j+y)%m;
doit[i][j]+=now[dx][dy];
}
}
}
}
for(int i=;i<n;i++)
for(int j=;j<m;j++)
now[i][j]=doit[i][j];
}
for(int i=;i<n;i++)
for(int j=;j<m;j++)
ans.insert(now[i][j]);
cout<<ans.size()<<endl;
return ;
}

K:DFS+回溯 注意!!!每个轮子只能有一个旋转状态 如果发生矛盾了就转不动了!

#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1.0e-6
#define PI acos(-1.0)
#define INF 3000000000
#define MOD 1000000009
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
int n;
int flag=-;
struct point
{
int x,y,r;
}a[];
vector<int> v[];
int visit[];
int ans=;
int anser;
bool check(point a,point b)
{
int dx=abs(a.x-b.x);
int dy=abs(a.y-b.y);
int dr=a.r+b.r;
if(dx*dx+dy*dy==dr*dr)
return true;
return false;
}
void dfs(int num,int now)
{
if(flag==)
return ;
for(int i=;i<v[num].size();i++)
{
int next=v[num][i];
if(flag==)
return ;
if(visit[next]==-)
{
visit[next]=now;
dfs(next,now^);
}
if(visit[next]!=now)
{
flag=;
return ;
}
}
}
int gcd(int x,int y){return y==?x:gcd(y,x%y);}
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
cin >> n;
mem(visit,-);
visit[]=;
for(int i=;i<=n;i++)
{
cin >> a[i].x >> a[i].y >> a[i].r;
}
for(int i=;i<n;i++)
for(int j=i+;j<=n;j++)
{
if(check(a[i],a[j]))
{
v[i].push_back(j);
v[j].push_back(i);
}
}
dfs(,);
if(flag==)
{
cout<<"The input gear cannot move."<<endl;
return ;
}
if(visit[n]==-)
{
cout<<"The input gear is not connected to the output gear."<<endl;
return ;
}
int chu=gcd(a[].r,a[n].r);
if(visit[]!=visit[n])
cout<<"-";
printf("%d:%d\n",a[].r/chu,a[n].r/chu);
return ;
}

Summer training #8的更多相关文章

  1. hdu 4946 2014 Multi-University Training Contest 8

    Area of Mushroom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  2. 2016 Multi-University Training Contests

    2016 Multi-University Training Contest 1 2016 Multi-University Training Contest 2 2016 Multi-Univers ...

  3. 2016 Multi-University Training Contest 2 D. Differencia

    Differencia Time Limit: 10000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  4. 2016 Multi-University Training Contest 1 G. Rigid Frameworks

    Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  5. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  6. The Solution of UESTC 2016 Summer Training #1 Div.2 Problem C

    Link http://acm.hust.edu.cn/vjudge/contest/121539#problem/C Description standard input/output After ...

  7. 2012 Multi-University Training Contest 9 / hdu4389

    2012 Multi-University Training Contest 9 / hdu4389 打巨表,实为数位dp 还不太懂 先这样放着.. 对于打表,当然我们不能直接打,这里有技巧.我们可以 ...

  8. 2014 Multi-University Training Contest 9#11

    2014 Multi-University Training Contest 9#11 Killing MonstersTime Limit: 2000/1000 MS (Java/Others)   ...

  9. 2014 Multi-University Training Contest 9#6

    2014 Multi-University Training Contest 9#6 Fast Matrix CalculationTime Limit: 2000/1000 MS (Java/Oth ...

  10. 2016 Multi-University Training Contest 1

    8/11 2016 Multi-University Training Contest 1 官方题解 老年选手历险记 最小生成树+线性期望 A Abandoned country(BH) 题意: 1. ...

随机推荐

  1. spark 1.6.0 安装与配置(spark1.6.0、Ubuntu14.04、hadoop2.6.0、scala2.10.6、jdk1.7)

    前几天刚着实研究spark,spark安装与配置是入门的关键,本人也是根据网上各位大神的教程,尝试配置,发现版本对应最为关键.现将自己的安装与配置过程介绍如下,如有兴趣的同学可以尝试安装.所谓工欲善其 ...

  2. 关于Npoi+excel文件读取,修改文件内容的处理方式

    因最近有需求场景,实现对文件的读写操作,又不单独生成新的文件,对于源文件的修改,做了一个简单实现,如下↓ // 要操作的excel文件路径 string fileName = Server.MapPa ...

  3. Nginx 配置文件解释及简单配置

    Nginx配置文件大致分为以下几个块 1.全局块:配置影响nginx全局的指令.一般有运行nginx服务器的用户组,nginx进程pid存放路径,日志存放路径,配置文件引入,允许生成worker pr ...

  4. Thinkphp 使用小结

    分页中带查询参数 ...->paginate(15,false,['query'=>request()->param()]); 队列后台自动开启运行 nohup php think ...

  5. vue 简易学习

    好记性不如烂笔头 最近公司新出一个框架,采用的是前后端分离的开发方式,后端用的是springboot+mybatis(还有额外的zk.缓存.日志等待),前端采用的是vue+es6,由于以前对vue只知 ...

  6. PAT B1006 换个格式输出整数 (15)

    AC代码 #include <cstdio> const int max_n = 3; char radix[max_n] = {' ', 'S', 'B'}; int ans[max_n ...

  7. MySQL 数据库的备份和恢复

    1.DOS命令 mysqldump /*DOS命令生成文本文件*/ mysqldump -u username -h host -ppassword dbname [tbanme1,tbname2,. ...

  8. Spring 的 Bean 管理(XML 方式)

    Spring 的 Bean 管理(XML 方式) 1. 三种实例化 Bean 的方式 使用类构造器实例化(默认无参数) 使用静态工厂方法实例化(简单工厂模式) 使用实例工厂方法实例化(工厂方法模式) ...

  9. PMP - 风险识别之风险登记册

    目录 PMP - 风险识别之风险登记册 1. 风险登记册 1.1 已识别风险的清单 1.2 潜在风险责任人 1.3 潜在风险应对措施清单 2. 相关习题 2.1 风险发生的时候,要实施 风险登记册 上 ...

  10. 排好序的数组中,找出两数之和为m的所有组合

    public static void main(String[] args) { int[] a = {1,2,2,3,3,4,5,6}; int m = 6; normal(a, m); } //正 ...