Codeforces Round #323 (Div. 2)
被进爷坑了,第二天的比赛改到了12点
/************************************************
* Author :Running_Time
* Created Time :2015/10/3 星期六 21:53:09
* File Name :A.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 55;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
bool r[N], c[N]; int main(void) {
memset (r, false, sizeof (r));
memset (c, false, sizeof (c));
int n; scanf ("%d", &n);
vector<int> ans;
n = n * n;
for (int x, y, i=1; i<=n; ++i) {
scanf ("%d%d", &x, &y);
if (!r[x] && !c[y]) {
r[x] = c[y] = true;
ans.push_back (i);
}
}
for (int i=0; i<ans.size (); ++i) {
printf ("%d%c", ans[i], (i == ans.size () - 1) ? '\n' : ' ');
} return 0;
}
/************************************************
* Author :Running_Time
* Created Time :2015/10/3 星期六 21:53:24
* File Name :B.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e3 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
int a[N]; int main(void) {
int n; scanf ("%d", &n);
for (int i=1; i<=n; ++i) {
scanf ("%d", &a[i]);
}
int ans = 0, d = 1, m = 0, p = 0;
bool flag = false;
while (true) {
if (d == 1) {
for (int i=p+1; i<=n; ++i) {
if (m >= a[i]) {
a[i] = INF;
m++; p = i;
flag = true;
}
}
if (m == n) break;
d ^= 1; ans++;
}
else {
for (int i=p-1; i>=1; --i) {
if (m >= a[i]) {
a[i] = INF;
m++; p = i;
flag = true;
}
}
if (m == n) break;
d ^= 1; ans++;
}
}
printf ("%d\n", ans); return 0;
}
题意:给了一张GCD表,问原来的求GCD的那些数
分析:从大到小找,最大的数和其他的数的GCD都不大于它,每次找到一个就能把它和已知的答案的GCD给删除,map+暴力就可以了
/************************************************
* Author :Running_Time
* Created Time :2015/10/3 星期六 21:53:35
* File Name :C.cpp
************************************************/
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 5e2 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
int a[N*N];
int ans[N];
map<int, int> cnt; int GCD(int a, int b) {
return b ? GCD (b, a % b) : a;
} int main(void) {
int n; scanf ("%d", &n);
int m = n;
n = n * n;
for (int i=1; i<=n; ++i) {
scanf ("%d", &a[i]);
cnt[-a[i]]++;
}
int pos = m;
map<int, int>::iterator it;
for (it=cnt.begin (); it!=cnt.end (); ++it) {
int x = -it -> first;
while (it -> second) {
ans[pos] = x;
--it -> second;
for (int i=pos+1; i<=m; ++i) {
cnt[-GCD (ans[pos], ans[i])] -= 2;
}
pos--;
}
} for (int i=1; i<=m; ++i) {
printf ("%d%c", ans[i], (i == m) ? '\n' : ' ');
} return 0;
}
Codeforces Round #323 (Div. 2)的更多相关文章
- Codeforces Round #323 (Div. 1) B. Once Again... 暴力
B. Once Again... Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/582/probl ...
- Codeforces Round #323 (Div. 2) C. GCD Table 暴力
C. GCD Table Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/583/problem/C ...
- 重复T次的LIS的dp Codeforces Round #323 (Div. 2) D
http://codeforces.com/contest/583/problem/D 原题:You are given an array of positive integers a1, a2, . ...
- Codeforces Round #323 (Div. 2) D. Once Again... 乱搞+LIS
D. Once Again... time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #323 (Div. 2) C. GCD Table map
题目链接:http://codeforces.com/contest/583/problem/C C. GCD Table time limit per test 2 seconds memory l ...
- Codeforces Round #323 (Div. 2) C.GCD Table
C. GCD Table The GCD table G of size n × n for an array of positive integers a of length n is define ...
- Codeforces Round #323 (Div. 1) A. GCD Table
A. GCD Table time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #323 (Div. 2) E - Superior Periodic Subarrays
E - Superior Periodic Subarrays 好难的一题啊... 这个博客讲的很好,搬运一下. https://blog.csdn.net/thy_asdf/article/deta ...
- Codeforces Round #323 (Div. 2) D 582B Once Again...(快速幂)
A[i][j]表示在循环节下标i开头j结尾的最长不减子序列,这个序列的长度为p,另外一个长度为q的序列对应的矩阵为B[i][j], 将两序列合并,新的序列对应矩阵C[i][j] = max(A[i][ ...
- Codeforces Round #323 (Div. 2) C GCD Table 582A (贪心)
对角线上的元素就是a[i],而且在所在行和列中最大, 首先可以确定的是最大的元素一定是a[i]之一,这让人想到到了排序. 经过排序后,每次选最大的数字,如果不是之前更大数字的gcd,那么只能是a[i] ...
随机推荐
- WPF DataGrid获取选择行的数据
在WPF中,单击DataGrid,如何获取当前点击的行? 比如在MouseDoubleClick事件中,事实上获取的选中行是一个DataRowview,你可以通过以下的方法来获取选中行的数据,需要引用 ...
- 1507: [NOI2003]Editor
1507: [NOI2003]Editor Time Limit: 5 Sec Memory Limit: 162 MB Submit: 3535 Solved: 1435 [Submit][St ...
- luogu3384 【模板】 树链剖分
题目大意 已知一棵包含N个结点的树(连通且无环),每个节点上包含一个数值,需要支持以下操作:操作1: 格式: 1 x y z 表示将树从x到y结点最短路径上所有节点的值都加上z操作2: 格式: 2 x ...
- dotnet core 入门
之前一至用的dotnet 做开发,项目没有用过.netcore,现在看微软对dotnetcore的重视度越来越高,所以dotnetcore也是每一个.dotnet开发人员的一项必备技能.一个偶然的机会 ...
- 一步一步学Silverlight 2系列文章
概述 由TerryLee编写的<Silverlight 2完美征程>一书,已经上市,在该系列文章的基础上补充了大量的内容,敬请关注.官方网站:http://www.dotneteye.cn ...
- 安装程序工具 (Installutil.exe)22
网址:https://msdn.microsoft.com/zh-cn/library/50614e95(VS.80).aspx 安装程序工具 (Installutil.exe) .NET Fram ...
- BZOJ_1713_[Usaco2007 China]The Bovine Accordion and Banjo Orchestra 音乐会_斜率优化
BZOJ_1713_[Usaco2007 China]The Bovine Accordion and Banjo Orchestra 音乐会_斜率优化 Description Input 第1行输入 ...
- c#操作rabbitmq
今天将会介绍如果使用rabbitmq进行简单的消息入队,出队操作,因为本文演示的环境要用到上文中配置的环境,所以要运行本文sample,请先按上一篇中完成相应环境配置. 首先,我们下载 ...
- Table View Programming Guide for iOS---(五)---Creating and Configuring a Table View
Creating and Configuring a Table View Your app must present a table view to users before it can mana ...
- Ubuntu中字体的改变
1.sudo dpkg-reconfigure console-setup 2.弹出 Configuring console-setup 界面,选择适当的编码格式,我们一般选择默认的UTF-8,选择O ...