Codeforces Round #324 (Div. 2) A, B, C, D, E
2015-10-09 16:13
363 查看
A. Olesya and Rodion
题目链接:
codeforces 584A. Olesya and Rodion
题目描述:
给出n, t, 问是否存在一个n位数能被t整除,能的话输出这个数,否则输出-1. 题目太水,加上题目描述是为了确保此题是此题,此题非彼题(看的是同一个题目)
解题思路:
当n=1,t=10时输出-1,其他时候先输出一个t,然后其他剩余的位置用0填补。
题目代码:
View Code
题目链接:
codeforces 584A. Olesya and Rodion
题目描述:
给出n, t, 问是否存在一个n位数能被t整除,能的话输出这个数,否则输出-1. 题目太水,加上题目描述是为了确保此题是此题,此题非彼题(看的是同一个题目)
解题思路:
当n=1,t=10时输出-1,其他时候先输出一个t,然后其他剩余的位置用0填补。
题目代码:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int maxn = 2010; int a[maxn], b[maxn], posb[maxn]; struct node { int x, y; node (int a = 0, int b = 0):x(a),y(b) {} } p[10000000]; int main () { int n; while (scanf ("%d", &n) != EOF) { for (int i=1; i<=n; i++) scanf ("%d", &a[i]); for (int i=1; i<=n; i++) { scanf ("%d", &b[i]); posb[b[i]] = i; } int res, nu; res = nu = 0; for (int i=1; i<=n; i++) { int x = i; for (int j=i-1; j>0; j--) { if (posb[a[j]]>=x && posb[a[x]]<=j) { swap (a[x], a[j]); res += abs (x - j); p[nu ++] = node(x, j); x = j; } } } printf ("%d\n%d\n", res, nu); for (int i=0; i<nu; i++) printf ("%d %d\n", p[i].x, p[i].y); } return 0; }
View Code
相关文章推荐
- no appropriate service handler found The Connection descriptor used by the client was: localhost:1521:myorcl
- iOS本地通知&定时通知
- 融合定位技术(FLP)介绍
- 配置ssh公钥
- 都是类型惹的祸——小心unsigned
- UESTC 87 Easy Problem With Numbers 线段树区间更新 逆元 分解质因数
- MD5加密32大写
- 强制格式化hadoop,清除HBase数据
- mysql入门笔记
- WIP_PERIOD_BALANCE 中找不到記錄
- win7下iis报503 Service Unavailable错误的解决方法
- hasOwnProperty和in
- Spring MVC表单上传场景下的验证
- [即时通讯]openfire启动失败解决办法
- 线性同余方程专题
- vim显示行号
- android获取屏幕宽高与获取控件宽高
- Go之单元测试
- javaWEB文件上传与下载
- 定制iOS 7中的导航栏和状态栏