Summer training #11
A:水
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define EPS 1.0e-8
#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 pb push_back
//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; //min
typedef long long ll;
typedef unsigned long long ull;
bool cmplow(int a,int b)
{
return a<b;
}
int num[];
int main()
{
freopen("bulls.in", "r", stdin);
freopen("bulls.out", "w", stdout);
mem(num,);
string a,b;
cin >> a >> b;
int n=,m=;
for(int i=;i<;i++)
{
num[a[i]-'']++;
}
for(int i=;i<;i++)
{
if(a[i]==b[i])
{
n++;
}
else
{
if(num[b[i]-'']!=)
m++;
}
}
cout<< n <<" "<< m;
}
B:要先搜 再记录路径 因为可走不代表是可行解 要后面门全部走完才能记录
include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define EPS 1.0e-8
#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 pb push_back
#define pai pair<int,int>
//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; //min
typedef long long ll;
typedef unsigned long long ull;
struct way
{
int to;
int val;
}w[];
int ans[];
int pop=;
void dfs(int x)
{
for(int gate=*x-;gate<=*x;gate++)
{
if(w[gate].val==)
{
w[w[gate].to].val=;
w[gate].val=;
dfs((w[gate].to+)/);
ans[pop++]=w[gate].to;
ans[pop++]=gate;
}
}
}
int main()
{
freopen("courier.in", "r", stdin);
freopen("courier.out", "w", stdout);
mem(ans,);
mem(w,);
int n;
cin >> n;
for(int i=;i<=*n;i++)
{
int now,next;
scanf("%d %d",&now,&next);
w[now].to=next;
w[next].to=now;
w[now].val=w[next].val=;
}
dfs();
for(int i=;i<=*n;i++)
{
if(w[i].val==)
{
cout<<"No"<<endl;
return ;
}
}
cout<<"Yes"<<endl;
cout<<ans[];
for(int i=;i<=*n;i++)
{
cout<<" "<<ans[i];
}
}
C:没遇到一个转折点就往前和往后推
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define EPS 1.0e-8
#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 pb push_back
//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; //min
typedef long long ll;
typedef unsigned long long ull;
int a[];
int ans[];
int pop=;
int main()
{
freopen("dales.in", "r", stdin);
freopen("dales.out", "w", stdout);
int t;
cin>> t;
while(t--)
{
int n;
cin >> n;
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
int h=,d=;
for(int i=;i<n;i++)
{
if(a[i]>a[i-]&&a[i]>a[i+])
{
int now1,now2;
for(now1=i-;now1>;now1--)
{
if(a[now1]>=a[now1+])
break;
}
for(now2=i+;now2<=n;now2++)
{
if(a[now2]>=a[now2-])
break;
}
h=max(h,min(now2-i-,i-now1-));
}
else if(a[i]<a[i-]&&a[i]<a[i+])
{
int now1,now2;
for(now1=i-;now1>;now1--)
{
if(a[now1]<=a[now1+])
break;
}
for(now2=i+;now2<=n;now2++)
{
if(a[now2]<=a[now2-])
break;
}
d=max(d,min(now2-i-,i-now1-));
}
}
cout<<h<<" "<<d<<endl;
}
}
D:暴力打表找规律
1->2->4->10->32->122->544->2770->15872->101042->707584->5405530......要算ans[x] i从1开始到x-2 add=ans[i]*ans[x-1-i]/2*C(x-1,i) if(i!=1&&(x-i-i)!=1) add/=2 ans+=add;
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define EPS 1.0e-8
#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 pb push_back
#define pai pair<int,int>
//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; //min
typedef long long ll;
typedef unsigned long long ull;
struct way
{
int to;
int val;
}w[];
int ans[];
int pop=;
void dfs(int x)
{
for(int gate=*x;gate>=*x-;gate--)
{
if(w[gate].val==)
{
w[w[gate].to].val=;
w[gate].val=;
dfs((w[gate].to+)/);
ans[pop++]=w[gate].to;
ans[pop++]=gate;
}
}
}
int main()
{
freopen("courier.in", "r", stdin);
freopen("courier.out", "w", stdout);
mem(ans,);
mem(w,);
int n;
cin >> n;
for(int i=;i<=*n;i++)
{
int now,next;
scanf("%d %d",&now,&next);
w[now].to=next;
w[next].to=now;
w[now].val=w[next].val=;
}
dfs();
for(int i=;i<=*n;i++)
{
if(w[i].val==)
{
cout<<"No"<<endl;
return ;
}
}
cout<<"Yes"<<endl;
cout<<ans[];
for(int i=;i<=*n;i++)
{
cout<<" "<<ans[i];
}
}
F:打表约数 枚举
G:数位DP
Summer training #11的更多相关文章
- 2017ecjtu-summer training # 11 POJ 2492
A Bug's Life Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 38280 Accepted: 12452 D ...
- 2017ecjtu-summer training #11 POJ 1018
Communication System Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 29218 Accepted: ...
- 壁虎书4 Training Models
Linear Regression The Normal Equation Computational Complexity 线性回归模型与MSE. the normal equation: a cl ...
- Todo List
Contest 11.13 2016ACM/ICPC亚洲区青岛站(5/13, solved 7/13) Training 11.06 2016年中国大学生程序设计竞赛(合肥)(solved 6/10) ...
- 每日英语:Boost Your Balance; Avoid Falls
If you find yourself needing to sit down to take off your shoes, it might be time to start paying at ...
- PyTorch中的Batch Normalization
Pytorch中的BatchNorm的API主要有: 1 torch.nn.BatchNorm1d(num_features, 2 3 eps=1e-05, 4 5 momentum=0.1, 6 7 ...
- 地区sql
/*Navicat MySQL Data Transfer Source Server : localhostSource Server Version : 50136Source Host : lo ...
- 2014 Multi-University Training Contest 9#11
2014 Multi-University Training Contest 9#11 Killing MonstersTime Limit: 2000/1000 MS (Java/Others) ...
- 【Android Developers Training】 11. 支持不同语言
注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...
随机推荐
- 线程回调,线程中的队列,事件,greenlet模块,gevent模块,自定义补丁, 单线程实现并发,协程
1.线程回调 在线程池/进程池每次提交任务,都会返回一个表示任务的对象,Future对象Future对象具备一个绑定方法,add_done_callback 用于指定回调函数 add 意味着可以添加多 ...
- 基于bootstrap模态框、fakeLoader实现全局遮罩层
一.fakeLoader.js介绍 fakeLoader.js 是轻量级的 jQuery 插件,帮助你创建动态的全屏加载掩饰微调效果,模拟页面预加载的效果. 插件下载地址:https://github ...
- ZOJ Problem Set - 1009
1.参考 http://blog.csdn.net/xiaogugood/article/details/17922105 这篇博客对算法介绍的很详细,我看这道题的时候,将题目理解出错,所以进入了一个 ...
- RDP爆破方式攻击防控思路梳理
- Java-Redis Serializable序列化
在Java中使用redis存储User对象时,进行JUnit测试时,控制台: 2019-06-24 16:56:45.520 INFO 27688 --- [ main] j.LocalContain ...
- 取整math函数
floor(a); ceil(a);
- PHP 协程:Go + Chan + Defer
Swoole4为PHP语言提供了强大的CSP协程编程模式.底层提供了3个关键词,可以方便地实现各类功能. Swoole4提供的PHP协程语法借鉴自Golang,在此向GO开发组致敬 PHP+Swool ...
- jdbc插入mysql时间差14个小时的解决方案
在java中new Date()输出的时间是没错的,插入到mysql后少了14个小时,原因是新版jdbc驱动的时区设置问题. 在jdbc连接url最后加上serverTimezone=GMT%2B8即 ...
- Spring 的 Bean 管理(XML 方式)
Spring 的 Bean 管理(XML 方式) 1. 三种实例化 Bean 的方式 使用类构造器实例化(默认无参数) 使用静态工厂方法实例化(简单工厂模式) 使用实例工厂方法实例化(工厂方法模式) ...
- 怎样理解 instanceof
instanceof 运算符用来判断一个对象在其原型链中是否存在一个构造函数的 prototype 属性. 也就是说, instanceof 判断的实际上是某个对象是否为某个构造函数的实例, 因为es ...