1101

#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y) int tree[N];
int n;
void add(int pos, int num) {
for(int i = pos; i <= n; i += i&-i) {
tree[i] += num;
}
}
int sum(int pos) {
int ans = 0;
for(int i = pos; i; i-= i&-i) {
ans += tree[i];
}
return ans;
}
struct Node{
int val, po, hh;
}E[N];
int cmp(Node a, Node b) {
return a.val < b.val;
}
int cmp2(Node a, Node b) {
return a.po < b.po;
}
int main() {
while(~scanf("%d", &n)) {
memset(tree, 0, sizeof(tree)); for(int i = 1; i <= n; ++i) {
scanf("%d", &E[i].val); E[i].po = i;
}
sort(E+1, E+n+1, cmp);
for(int i = 1; i <= n; ++i) {
E[i].hh = i;
}
sort(E+1, E+n+1, cmp2); int ans = 0;
vector<int> vc;
for(int i = 1; i <= n; ++i) {
int tt = sum(E[i].hh);
// printf("%d %d\n", tt, E[i].val);
if(tt == E[i].hh-1 && E[i].hh == i) ans ++, vc.push_back(E[i].val);
add(E[i].hh, 1);
}
printf("%d\n", ans);
for(int i = 0; i < vc.size(); ++i) {
if(i) printf(" ");
printf("%d", vc[i]);
} printf("\n");
}
return 0;
}

1102

#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 15;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y) int L[N];
int R[N];
int has[N];
void bfs(int x) {
queue<int> Q;
Q.push(x);
int fl = 0;
while(!Q.empty()) {
int tt = Q.front(); Q.pop();
if(!fl) fl = 1;
else printf(" ");
printf("%d", tt);
if(R[tt] != INF) Q.push(R[tt]);
if(L[tt] != INF) Q.push(L[tt]);
}
}
vector<int> vc;
int ff;
void dfs(int x) {
// printf("%d\n", x);
if(L[x] != INF) dfs(L[x]);
vc.push_back(x);
if(R[x] != INF) dfs(R[x]);
}
int main() {
int n;
while(~scanf("%d", &n)) {
ff = 0;
for(int i = 0; i < n; ++i) {
L[i] = INF; R[i] = INF;
}
memset(has, 0, sizeof(has)); for(int i = 0; i < n; ++i) {
char a[10], b[10];
scanf("%s %s", a, b);
// printf("%d %d\n", a[0]-'0', b[0]-'0');
if(a[0] != '-') {
L[i] = a[0]-'0'; has[a[0]-'0'] ++;
}
if(b[0] != '-') {
R[i] = b[0]-'0'; has[b[0]-'0'] ++;
}
} for(int i = 0; i < n; ++i) {
if(!has[i]) {
bfs(i);
printf("\n");
dfs(i);
break;
}
}
for(int i = vc.size()-1; i >= 0; --i) {
if(i != vc.size()-1) printf(" ");
printf("%d", vc[i]);
} printf("\n"); }
return 0;
}

1103爆搜,没怎么剪

#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 15;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y) int Pow(int x, int y) {
int ans = 1;
while(y) {
if(y & 1) ans *= x;
x *= x;
y >>= 1;
}
return ans;
}
vector<int> tmp;
vector<int> ans; void jud() { if(ans.size() == 0) {
for(int i = 0; i < tmp.size(); ++i) ans.push_back(tmp[i]);
} else {
int t1 = 0;
for(int i = 0; i < ans.size(); ++i) t1 += ans[i];
int t2 = 0;
for(int i = 0; i < tmp.size(); ++i) t2 += tmp[i]; if(t1 < t2) {
ans.clear();
for(int i = 0; i < tmp.size(); ++i) ans.push_back(tmp[i]);
}else {
int fl = 0;
for(int i = 0; i < min( tmp.size(), ans.size() ); ++i) {
if(tmp[i] != ans[i]) {
if(tmp[i] > ans[i]) {
fl = 1;
}
break;
}
}
if(fl) {
ans.clear();
for(int i = 0; i < tmp.size(); ++i) ans.push_back(tmp[i]);
}
}
}
}
void dfs(int x, int y, int z, int maxx) { if(y == 1) {
if(x) {
int num = pow(x, 1.0/z);
if( pow(num, z) == x) {
int num = pow(x, 1.0/z);
tmp.push_back(num);
jud();
tmp.erase(--tmp.end());
}
}
return;
}
else if(maxx * y == x) {
int num = pow(maxx, 1.0/z);
for(int i = 1; i <= y; ++i) tmp.push_back(num);
jud();
for(int i = 1; i <= y; ++i) tmp.erase(--tmp.end());
return;
} for(int i = min((int)pow(x, 1.0/z), maxx) ; i >= 1; --i) {
int tt = pow(i, z);
if(tt*y < x) continue;
tmp.push_back(i);
dfs(x-tt, y-1, z, i);
tmp.erase(--tmp.end());
}
}
int main() {
int n, k, p;
while(~scanf("%d %d %d", &n, &k, &p)) {
tmp.clear(); ans.clear();
dfs(n, k, p, INF); if(ans.size() == 0) {
printf("Impossible\n");
}else {
printf("%d =", n);
for(int i = 0; i < ans.size(); ++i) {
if(i) printf(" +");
printf(" %d^%d", ans[i], p);
}
printf("\n");
}
}
return 0;
}

1104

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<map>
#include<set> using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int N = 1e5+5;
typedef long long ll;
#define MP(x, y) make_pair(x, y) double a[N];
int main() {
int n;
while(~scanf("%d", &n)) {
double ans = 0;
for(int i = 0; i < n; ++i) {
scanf("%lf", &a[i]);
ans += a[i] * (i+1) * (n-i);
}
printf("%.2f\n", ans); }
return 0;
}

1105

#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1e4+5;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y) int a[N];
int wid, hei;
map<pair<int, int>, int> mp;
int cmp(int a, int b) {
return a > b;
}
void solve(int id, int stx, int sty, int W, int H) {
if(W == 1) {
for(int i = sty; i <= sty+H-1; ++i) {
mp[MP(stx, i)] = a[id++];
}
return;
}else if(H == 1) {
for(int i = stx; i <= stx+W-1; ++i) {
mp[MP(i, sty)] = a[id++];
}
return;
} int X = stx; int Y = sty;
for(; X <= stx + W-1; ++X) {
mp[MP(X, Y)] = a[id ++];
// printf("%d %d\n", X, Y, a[id-1]);
}
X--; Y++; for(; Y <= sty + H-1; ++Y) {
mp[MP(X, Y)] = a[id ++];
}
Y--; X--;
for(; X >= stx; --X) {
mp[MP(X, Y)] = a[id ++];
}
X++; Y--;
for(; Y > sty; --Y) {
mp[MP(X, Y)] = a[id ++];
}
if(W-2 > 0 && H-2 > 0) solve(id, ++X, ++Y, W-2, H-2);
} int main() {
int n;
while(~scanf("%d", &n)) {
mp.clear();
for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
sort(a, a+n, cmp); for(int i = 1; i <= sqrt(n); ++i) {
if(n % i == 0) {
wid = i;
}
} hei = n/wid;
// printf("%d %d\n", wid, hei);
solve(0, 0,0, wid, hei);
for(int i = 0; i < hei; ++i) {
for(int j = 0; j < wid; ++j) {
if(j) printf(" ");
printf("%d", mp[MP(j, i)]);
}
printf("\n");
}
}
return 0;
}

1106

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<map>
#include<set> using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5+5;
typedef long long ll;
#define MP(x, y) make_pair(x, y) int n; double p, r;
struct Node{
int to, nx;
}E[N*1000];
int has[N];
int head[N]; int tot;
void add(int fr, int to) {
E[tot].to = to; E[tot].nx = head[fr]; head[fr] = tot++;
}
double ans;
vector<double> vc;
void dfs(int x, double price) {
if(!has[x]) {
if(ans > price) {
ans = price;
}
vc.push_back(price);
return;
}
for(int i = head[x]; ~i; i = E[i].nx) {
int to = E[i].to;
dfs(to, price*(1+ r/100));
}
}
int main() {
while(~scanf("%d %lf %lf", &n, &p, &r)) {
ans = INF;
vc.clear();
memset(head, -1, sizeof(head));
memset(has, 0, sizeof(has));
tot = 0;
int root;
for(int i = 0; i < n; ++i) {
int a; scanf("%d", &a);
for(int j = 0; j < a; ++j) {
int b; scanf("%d", &b);
add(i, b);
has[i] ++;
}
} dfs(0, p);
int all = 0;
for(int i = 0; i < vc.size(); ++i) {
if(vc[i] == ans) {
all ++;
}
}
printf("%.4f %d\n", ans , all);
}
return 0;
}

1107 题意不清,,,我猜是并查集,反正对了

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<map>
#include<set> using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e3+5;
typedef long long ll;
#define MP(x, y) make_pair(x, y) vector<int> hob[N];
int f[N];
int cnt[N];
int find(int x) {
return x==f[x]? x : f[x] = find(f[x]);
}
int cmp(int a, int b) {
return a > b;
}
int main() {
int n;
while(~scanf("%d", &n)) {
for(int i = 0; i < n; ++i) f[i] = i; for(int i = 0; i < n; ++i) {
int a; scanf("%d:", &a);
for(int j = 0; j < a; ++j) {
int b; scanf("%d", &b);
hob[b].push_back(i);
}
} for(int i = 1; i <= 1000; ++i) {
if(hob[i].size() > 1) {
for(int j = 1; j < hob[i].size(); ++j) {
int t1 = find(hob[i][0]); int t2 = find(hob[i][j]);
if(t1 != t2) f[t2] = t1;
}
}
} for(int i = 0; i < n; ++i) {
int t1 = find(i);
cnt[t1] ++;
}
sort(cnt, cnt+n, cmp);
int all = 0;
for(int i = 0; i < n; ++i) {
if(cnt[i]) {
all ++;
}
}
printf("%d\n", all);
for(int i = 0; i < n; ++i) {
if(!cnt[i]) break;
if(i) printf(" ");
printf("%d", cnt[i]);
} printf("\n"); }
return 0;
}

1108

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<map>
#include<set> using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e3+5;
typedef long long ll;
#define MP(x, y) make_pair(x, y) int main() {
int n;
while(~scanf("%d", &n)) {
double ans = 0; int ansp = 0;
for(int i = 0; i < n; ++i) {
char s[30]; scanf("%s", s); int fl = 1; int zhen = 1;
if(s[0] == '-') zhen *= -1; int len = strlen(s);
for(int cnt = 0, j = (zhen==-1) ; j < len; ++j) {
if(s[j] == '.') {
if(len-j > 3 || j == (zhen==-1) ) {
fl = 0;
break;
}
cnt ++;
if(cnt > 1) {
fl = 0; break;
}
} else if( s[j] >= '0' && s[j] <= '9');
else {
fl = 0; break;
}
} if(fl) {
double tt;
sscanf(s, "%lf", &tt);
if(tt < -1000 || tt > 1000) {
fl = 0;
}else ansp ++, ans += tt;
}
if(!fl) printf("ERROR: %s is not a legal number\n", s);
} if(ansp == 0) printf("The average of 0 numbers is Undefined\n");
else if(ansp == 1) printf("The average of %d number is %.2f\n", ansp, ans/ansp);
else printf("The average of %d numbers is %.2f\n", ansp, ans/ansp); }
return 0;
}

1109

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<map>
#include<set> using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e4+5;
typedef long long ll;
#define MP(x, y) make_pair(x, y) char nam[N][10];
struct Node{
int id, grade;
}E[N];
int cmp(Node a, Node b) {
if(a.grade != b.grade) return a.grade > b.grade;
else {
char *A = nam[a.id]; char *B = nam[b.id];
int l1 = strlen(A); int l2 = strlen(B); for(int i = 0; i < min(l1, l2); ++i) {
if(A[i] != B[i])
return A[i] < B[i];
}
return l1 < l2;
}
}
int value[N];
int main() {
int n, p;
while(~scanf("%d %d", &n, &p)) {
for(int i = 0; i < n; ++i) {
scanf("%s %d", nam[i], &E[i].grade);
E[i].id = i;
}
sort(E, E+n, cmp);
// for(int i = 0; i < n; ++i) printf("%s ", nam[E[i].id]); printf("\n"); int rownum = n/p; for(int i = 0; i < n; i += rownum) {
int l = i; int r = i+rownum-1;
// printf("%d %d\n", l, r);
if(i == 0) r += n%p;
// printf("%d %d\n", l, r); int L = (r-l+1)/2 + l; int R = L;
// printf("%d %d\n", L, R);
int cnt = l;
while(1) {
if(L == R) value[L] = cnt++;
else {
if(L >= l) value[L] = cnt++;
if(R <= r) value[R] = cnt++;
}
L --; R ++;
if(L < l && R > r) break;
}
for(int i = l; i <= r; ++i) {
if(i != l) printf(" ");
printf("%s", nam[E[value[i]].id]);
}
printf("\n");
if(i == 0) i += n%p;
}
}
return 0;
}

1110原来傻逼错误是 字符串转数字那里,醉了

include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 25;
const int INF = 0x3f3f3f3f;
#define MP(x, y) make_pair(x, y) int L[N];
int R[N];
int has[N];
int all;
int ok[N];
int cnt[N]; int ansdep; int ans; void bfs(int x) {
queue<pair<int ,int> > Q;
Q.push(MP(x, 0));
while(Q.front().first != INF) {
int po = Q.front().first; int dep = Q.front().second; Q.pop();
// printf("%d\n", po);
all ++;
cnt[dep] ++;
if(dep >= ansdep) {
ansdep = dep;
ans = po;
}
Q.push(MP(L[po], dep+1));
Q.push(MP(R[po], dep+1));
}
}
int main() {
int n;
while(~scanf("%d", &n)) {
all = 0;
memset(ok, 0, sizeof(ok));
memset(cnt, 0, sizeof(cnt)); for(int i = 0; i < n; ++i) {
L[i] = INF; R[i] = INF;
}
memset(has, 0, sizeof(has)); for(int i = 0; i < n; ++i) {
char a[10], b[10];
scanf("%s %s", a, b);
int tt;
// printf("%d %d\n", a[0]-'0', b[0]-'0');
if(a[0] != '-') {
sscanf(a,"%d", &tt);
L[i] = tt; has[tt] ++;
}
if(b[0] != '-') {
sscanf(b,"%d", &tt);
R[i] = tt; has[tt] ++;
}
} int root;
for(int i = 0; i < n; ++i) {
if(!has[i]) {
all = 0; ansdep = -1;
bfs(i);
root = i;
break;
}
}
// printf("%d\n", all); if(all == n) printf("YES %d\n", ans);
else { printf("NO %d\n", root); } }
return 0;
}

pat1101-1110的更多相关文章

  1. BZOJ 1110: [POI2007]砝码Odw

    1110: [POI2007]砝码Odw Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 547  Solved: 296[Submit][Status ...

  2. ural 1110,快速幂

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1110 题意:   X^N % M = Y,X=[0,M-1];没有输出-1: #incl ...

  3. BZOJ 1110: [POI2007]砝码Odw( 贪心 )

    ORZjcvb... #include<bits/stdc++.h> using namespace std; ; int N, M, item[maxn], V[maxn]; vecto ...

  4. 案例:Standby RAC遭遇ORA-1157,1111,1110导致实例crash处理

    案例:Standby RAC遭遇ORA-1157,1111,1110导致实例crash处理 环境:RHEL 6.5 + Oracle RAC 11.2.0.4 + Dataguard 今天在实验环境的 ...

  5. CF 1110 D/E

    CF 1110 D. Jongmah 题目大意:给你​\(n\)个瓷砖,每块瓷砖上有一个数字​\(a_i,(1\leq a_i\leq m)\).你可以将三个有连续数字​\((比如3,4,5)\)的瓷 ...

  6. 【Codeforces Round 1110】Codeforces Global Round 1

    Codeforces Round 1110 这场比赛只做了\(A\).\(B\).\(C\),排名\(905\),不好. 主要的问题在\(D\)题上,有\(505\)人做出,但我没做出来. 考虑的时候 ...

  7. 洛谷.1110.[ZJOI2007]报表统计(Splay Heap)

    题目链接 附纯SplayTLE代码及主要思路: /* 可以看做序列有n段,Insert是每次在每一段最后插入一个元素 只有插入,没有删除,所以插入一个元素对于询问1影响的只有该元素与前边一个元素(同段 ...

  8. CodeForces Contest #1110: Global Round 1

    比赛传送门:CF #1110. 比赛记录:点我. 涨了挺多分,希望下次还能涨. [A]Parity 题意简述: 问 \(k\) 位 \(b\) 进制数 \(\overline{a_1a_2\cdots ...

  9. 1110 Complete Binary Tree (25 分)

    1110 Complete Binary Tree (25 分) Given a tree, you are supposed to tell if it is a complete binary t ...

  10. [二叉树建树&完全二叉树判断] 1110. Complete Binary Tree (25)

    1110. Complete Binary Tree (25) Given a tree, you are supposed to tell if it is a complete binary tr ...

随机推荐

  1. 700名黑客无法攻破Trillium安全防护软件 欲以网络安全险获利

    盖世汽车讯 据外媒报道,在2017 DEF CON黑客大会上,黑客们受邀入侵Car Hacking Village会场内的各类自动驾驶车辆.物联网网络安全公司--Trillium Incorporat ...

  2. python基础 列表 的使用

    列表 首先定义一个列表 声明列表 列表名字=[值1,值2] list=[1,2,3,4,5] 这是一个列表,列表中有五个元素(1,2,3,4,5) 显示list列表 print   list 输出   ...

  3. BZOJ 2419: 电阻 [高斯消元 物理]

    http://www.lydsy.com/JudgeOnline/problem.php?id=2419 题意: n个点m个电阻构成一张图,求1到n的等效电阻 第一节课看一道题弃疗,于是来做这道物理题 ...

  4. 使用VS Code开发asp.net core (下)

    第一部分: https://www.cnblogs.com/cgzl/p/8450179.html 本文是基于Windows10的. Debugging javascript 打开wwwroot/js ...

  5. JavaScript正则表达式函数总结

    /* 测试环境:Chrome 63.0.3239.132 */ JS中正则对象修饰符可选值为:"i" "g" "m",即忽略大小写 进行全局 ...

  6. PyCharm安装及使用

    搭建环境 1.win10_X64,其他Win版本也可以. 2.PyCharm版本:Professional-2016.2.3. 搭建准备 1.到PyCharm官网下载PyCharm安装包.   Dow ...

  7. [JSOI2008]最大数maxnumber

    [JSOI2008]最大数maxnumber 标签: 线段树 单独队列 题目链接 题解 线段树裸题. 如果一直RE可能是你用的cin/cout. Code #include<cstdio> ...

  8. 使用腾讯云“自定义监控”监控GPU使用率

    欢迎大家前往云+社区,获取更多腾讯海量技术实践干货哦~ 作者:李想 随着人工智能以及比特币的火热,GPU云服务的使用场景是越来越广,在很多场景下我们也需要获取GPU服务器的性能参数来优化程序的执行.目 ...

  9. 卷积神经网络(CNN)在句子建模上的应用

    之前的博文已经介绍了CNN的基本原理,本文将大概总结一下最近CNN在NLP中的句子建模(或者句子表示)方面的应用情况,主要阅读了以下的文献: Kim Y. Convolutional neural n ...

  10. Linux系统软件安装的几种方式

    Linux系统,一个文件能不能执行看的是有没有可执行权限x,不过真正的可执行文件是二进制文件(binary file),举例来说Linux上的c语言源码编写完后,通过gcc程序编译后就可以创建一个可执 ...