被进爷坑了,第二天的比赛改到了12点

水 A - Asphalting Roads

/************************************************
* 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;
}

水 B - Robot's Task

/************************************************
* 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;
}

贪心 C - GCD Table

题意:给了一张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)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 重复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, . ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #323 (Div. 2) E - Superior Periodic Subarrays

    E - Superior Periodic Subarrays 好难的一题啊... 这个博客讲的很好,搬运一下. https://blog.csdn.net/thy_asdf/article/deta ...

  9. 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][ ...

  10. Codeforces Round #323 (Div. 2) C GCD Table 582A (贪心)

    对角线上的元素就是a[i],而且在所在行和列中最大, 首先可以确定的是最大的元素一定是a[i]之一,这让人想到到了排序. 经过排序后,每次选最大的数字,如果不是之前更大数字的gcd,那么只能是a[i] ...

随机推荐

  1. (转载)js(jquery)的on绑定点击事件执行两次的解决办法

    js(jquery)的on绑定点击事件执行两次的解决办法—不是事件绑定而是事件冒泡 遇到的问题:jquery中用.on()给页面中新加的元素添加点击事件时,点击事件源,绑定的事件执行两次,这里的ale ...

  2. Android — 长按ListView 利用上下文菜单(ActionMode) 进行批量事件处理

    好久没写博客拉``````` 近期最终略微闲一点了``````` 无聊拿手机清理短信.发现批量事件的处理还是挺管用的`````` 那么自己也来山寨一记看看效果吧````` 闲话少说,首先,我们来看下手 ...

  3. PHP获取类名及所有函数名

    PHP获取当前类名.方法名  __CLASS__ 获取当前类名  __FUNCTION__ 当前函数名(confirm)  __METHOD__ 当前方法名 (bankcard::confirm) _ ...

  4. GUI界面资源

    30个真棒的(免费iPhone,iPad IOS)的GUI 界面设计元素模板 做iphone开发的福音   创造力是指任何一种演示设计i的能力.无论是一个标志,旗帜,广告或一个完整的设计,能够注入的创 ...

  5. date format记录

    各种日期格式定义,容易忘记,这里备注下: * 支持格式为 yyyy.MM.dd G 'at' hh:mm:ss z 如 '2002-1-1 AD at 22:10:59 PSD'<br> ...

  6. jsorder 第三方修改版 修正bug 增加总价

    我主要运用这个jsorder,修正了它的不足//1.0版本bug:刷新页面 无法增加或者删除原来添加的商品//1.1版本:修正了1.0版本  新增bug 能够修改原来的商品 但出现产品数量为0 仍然保 ...

  7. jsp的4大作用域

    jsp的4大作用域 首先要声明一点,所谓“作用域”就是“信息共享的范围”,也就是说一个信息能够在多大的范围内有效.4个JSP内置对象的作用域分别为:application.session.reques ...

  8. oracle:数据库版本问题导致的bug

    公司开发出来的系统,由于各现场oracle数据库版本有10.2.0.4.11.2.0.1.11.2.0.3.11.2.0.4: 进而会导致版本不一导致错误问题.下面列举2个: 1.wm_concat ...

  9. liunx操作系统安装<一>

    一:磁盘分区类型(1)主分区(最多四个主分区,比如window系统的C盘,D盘)(2)扩展分区,逻辑分区(为了能让磁盘多分出几个区域而存在)(3)交换分区(虚拟内存,当物理内存不足时候,作为应急存在)

  10. 基于redis实现tomcat8的tomcat集群的session持久化实现(tomcat-redis-session-manager二次开发)

    前言: 本项目是基于jcoleman的tomcat-redis-session-manager二次开发版本 1.修改了小部分实现逻辑 2.去除对juni.jar包的依赖 3.去除无效代码和老版本tom ...