被进爷坑了,第二天的比赛改到了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. 使网页适应UIWebView的宽度

    比較简单的做法是:在- (void)webViewDidFinishLoad:这种方法中,改动JavaScript的值: //UIWebViewDelegate - (void)webViewDidF ...

  2. 文件宝局域网传输/播放功能使用帮助(Windows电脑用户)

    使用局域网账户密码登录,可以访问电脑上所有文件 使用游客无账户密码登录,只能访问电脑上指定共享文件夹的文件. 1.怎么设置共享文件夹请参考: 方法1 1.在文件资源管理器中选择自己一个想共享的文件夹, ...

  3. 1507: [NOI2003]Editor

    1507: [NOI2003]Editor Time Limit: 5 Sec  Memory Limit: 162 MB Submit: 3535  Solved: 1435 [Submit][St ...

  4. CarbonData

    CarbonData http://carbondata.apache.org/ Apache顶级项目CarbonData应用实践与2.0新技术规划介绍_搜狐科技_搜狐网 https://www.so ...

  5. 推断View是否显示在界面上

    我们都知道ViewController有viewWillAppear和viewDidAppear等关于页面生命周期的方法,用来对视图做一些管理,比方页面出现时怎么样,页面消失时怎么样.. 可是对于Vi ...

  6. kbmMW 5.0.1发布了(跨全平台,包括Linux,可使用Win的高性能HTTPSys传输层,等等)

    kbmMW5如期发布,作者增加了很多重磅功能,以下翻译作者的发布文件:1.支持Delphi 10.2 Tokyo,包括Linux支持(测试版)2.大量的新功能与改进3.新的智能服务(Smart ser ...

  7. react native 之 redux

    第一章  认识redux 说的通俗且直白一点呢,就是redux提供了一个store,独立的一个内存区,然后放了一些state,你可以在任何component中访问到state,这些state要更改怎么 ...

  8. 异常、Throwable、finally、File类(十九)

    1.异常的概述和分类 * A:异常的概述 * 异常就是Java程序在运行过程中出现的错误.* B:异常的分类 * 通过API查看Throwable * Error * 服务器宕机,数据库崩溃等 * E ...

  9. 为什么越来越多公链项目将WASM拥入怀中?

    最近越来越多的项目开始转向VNT使用的WASM,像EOS.Ontology,包括最初引入虚拟机EVM运行智能合约环境的以太坊,最近也开始转向使用WASM. 什么是WASM? WASM ,全称:WebA ...

  10. 【hdu 5418】 Victor and world

    [题目链接] 点击打开链接 [算法] 状压DP f[i][S]表示走的最后一步在i,状态为S 于是我们可以用最短路径 + 状压DP解决此题,由于不存在负边,所以可以用dijkstra+堆优化 [代码] ...