【索引】Volume 0. Getting Started
AOAPC I: Beginning Algorithm Contests (Rujia Liu)
Volume 0. Getting Started
![]() |
10055 - Hashmat the Brave Warrior | 153793 |
27.33%
|
33385 |
85.74%
|
![]() |
10071 - Back to High School Physics | 76581 |
50.07%
|
28855 |
93.71%
|
![]() |
10300 - Ecological Premium | 26621 |
66.39%
|
15397 |
96.67%
|
![]() |
458 - The Decoder | 53026 |
47.65%
|
19817 |
92.60%
|
![]() |
494 - Kindergarten Counting Game | 50741 |
37.94%
|
17306 |
88.44%
|
![]() |
414 - Machined Surfaces | 15779 |
43.57%
|
6212 |
92.14%
|
![]() |
490 - Rotating Sentences | 31459 |
28.06%
|
8462 |
78.31%
|
![]() |
445 - Marvelous Mazes | 25516 |
41.20%
|
8877 |
85.10%
|
![]() |
488 - Triangle Wave | 64113 |
21.00%
|
14397 |
64.00%
|
![]() |
489 - Hangman Judge | 18406 |
26.42%
|
5871 |
60.77%
|
![]() |
694 - The Collatz Sequence | 24814 |
39.03%
|
8554 |
87.32%
|
![]() |
457 - Linear Cellular Automata | 7589 |
33.79%
|
2571 |
81.56%
|
uva 10055 Hashmat the brave warrior
题目大意:求两个数的差,注意上限。
#include <stdio.h>
int main() {
long long a, b;
while (scanf("%lld%lld", &a, &b) == 2) {
printf("%lld\n", a > b ? a - b : b - a);
}
return 0;
}
uva 10071 Back to High School Physics
题目大意:计算2 * a * b。
#include <stdio.h>
int main() {
int v, t;
while (scanf("%d%d", &v, &t) == 2) {
printf("%d\n", 2 * v * t);
}
return 0;
}
#include <stdio.h>
int main() {
int cas;
int n, size, ani, val;
scanf("%d", &cas);
while (cas--) {
int sum = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d%d%d", &size, &ani, &val);
sum += size * val;
}
printf("%d\n", sum);
}
return 0;
}
#include <stdio.h>
#include <string.h>
const int N = 1005;
int main() {
char s[N];
while (gets(s)) {
int len = strlen(s);
for (int i = 0; i < len; i++)
s[i] = s[i] - 7;
puts(s);
}
return 0;
}
uva 494 Kindergarten Counting Game
#include <stdio.h>
#include <string.h> const int N = 10005; bool judge(char c) {
if (c >= 'a' && c <= 'z')
return true;
else if (c >= 'A' && c <= 'Z')
return true;
return false;
} int main() {
char str[N];
while (gets(str)) {
int len = strlen(str), flag = 0, n = 0;
for (int i = 0; i < len; i++) {
if (judge(str[i])) {
if (flag) continue;
flag = 1;
n++;
}
else
flag = 0;
}
printf("%d\n", n);
}
return 0;
}
#include <stdio.h>
#include <string.h> const int N = 10005; int count(char str[]) {
int cnt = 0, len = strlen(str);
for (int i = 0; i < len; i++)
if (str[i] == 'X')
cnt++;
return cnt;
} int main() {
char str[N];
int n, max, sum, tmp;
while (scanf("%d%*c", &n), n) {
max = sum = 0;
for (int i = 0; i < n; i++) {
gets(str);
tmp = count(str);
if (max < tmp)
max = tmp;
sum += tmp;
}
printf("%d\n", max * n - sum );
}
return 0;
}
#include <stdio.h>
#include <string.h>
const int N = 107;
char str[N][N]; int main() {
int n = 0, len = 0;
memset(str, 0, sizeof(str));
while (gets(str[n])) {
int a = strlen(str[n++]);
if (len < a)
len = a;
} for (int i = 0; i < n; i++)
for (int j = 0; j < len; j++)
if (!str[i][j])
str[i][j] = ' '; for (int i = 0; i < len; i++) {
for (int j = n - 1; j >= 0; j--)
printf("%c", str[j][i]);
printf("\n");
}
return 0;
}
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std; int main() {
string str;
while (getline(cin, str)) {
int len = str.length(), cnt = 0;
for (int i = 0; i < len; i++) {
if (str[i] >= '0' && str[i] <= '9')
cnt += str[i] - '0';
else if (str[i] == '!')
printf("\n");
else {
for (int j = 0; j < cnt; j++)
printf("%c", str[i] != 'b' ? str[i] : ' ');
cnt = 0;
}
}
printf("\n");
}
return 0;
}
#include <stdio.h> void print(int len, int n) {
while (n--) {
for (int i = 1; i <= len; i++) {
for (int j = 0; j < i; j++)
printf("%d", i);
printf("\n");
}
for (int i = len - 1; i > 0; i--) {
for (int j = 0; j < i; j++)
printf("%d", i);
printf("\n");
}
if (n) printf("\n");
}
} int main() {
int cas, len, n;
scanf("%d", &cas);
while (cas--) {
scanf("%d%d", &len, &n);
print(len, n);
if (cas) printf("\n");
}
return 0;
}
#include <stdio.h>
#include <string.h>
const int N = 30;
const int M = 10005;
int answer[N], gass[N];
int cntAnswer, cntWrong; int main() {
int cas;
char str[M];
while (scanf("%d", &cas), cas != -1) {
// Init;
memset(answer, 0, sizeof(answer));
memset(gass, 0, sizeof(gass));
cntAnswer = cntWrong = 0; scanf("%s", str); int len = strlen(str);
for (int i = 0; i < len ; i++) {
if (answer[str[i] - 'a'] == 0) {
answer[str[i] - 'a'] = 1;
cntAnswer++;
}
} scanf("%s", str); len = strlen(str);
for (int i = 0; i < len; i++) {
if (gass[str[i] - 'a']) continue;
if (answer[str[i] - 'a'])
cntAnswer--;
else
cntWrong++;
gass[str[i] - 'a'] = 1;
if (cntAnswer == 0 || cntWrong == 7)
break;
} printf("Round %d\n", cas);
if (cntAnswer)
printf("%s\n", cntWrong != 7 ? "You chickened out." : "You lose.");
else
printf("You win.\n");
}
return 0;
}
#include <stdio.h>
int main() {
long long cur, max, cnt, cas = 1, rec;
while (scanf("%lld%lld", &cur, &max)) {
if (cur < 0 || max < 0) break;
cnt = 1;
rec = cur;
while (cur != 1) {
if (cur % 2)
cur = 3 * cur + 1;
else
cur = cur / 2;
if (cur > max) break;
cnt++;
}
printf("Case %lld: A = %lld, limit = %lld, number of terms = %lld\n", cas++, rec, max, cnt);
}
return 0;
}
uva 457 Linear Cellular Automata
#include <stdio.h>
#include <string.h>
const int N = 42;
const char sign[] = " .xW";
int DNA[10], tmp[N], rec[N]; int main() {
int cas;
scanf("%d", &cas);
while (cas--) {
// Init
memset(DNA, 0, sizeof(DNA));
memset(tmp, 0, sizeof(tmp));
memset(rec, 0, sizeof(rec));
tmp[20] = rec[20] = 1; for (int i = 0; i < 10; i++)
scanf("%d", &DNA[i]); for (int data = 1; data <= 50; data++) {
for (int i = 1; i <= 40; i++)
printf("%c", sign[tmp[i]]);
printf("\n"); for (int i = 1; i <= 40; i++)
rec[i] = DNA[tmp[i - 1] + tmp[i] + tmp[i + 1]];
memcpy(tmp, rec, sizeof(rec));
}
if (cas)
printf("\n");
}
return 0;
}
【索引】Volume 0. Getting Started的更多相关文章
- FlipView 索引为0 WP8.1
如果使用FlipView时,出现别的页面切换到含有FlipView的页面时(缓存此页面/MainPage),点击或者滑动FlipView,Flipview自动索引到0 的问题解决办法 1.对Flipv ...
- C++索引从0开始的堆排序算法实现
更新2019年11月4日 04:26:35 睡不着觉起来寻思寻思干点啥吧,好像好久没写堆排了.于是写了个索引从0开始的堆排,这次把建堆函数略了并在heapsort主函数里,索引从0开始到size-1结 ...
- Python自学:第三章 索引从0开始而不是从1
#返回最后一个,和倒数第二个元素 bicycles = ['trek','cannondale','redline','specialized'] print(bicycles[-1]) print( ...
- Solr4.8.0源码分析(10)之Lucene的索引文件(3)
Solr4.8.0源码分析(10)之Lucene的索引文件(3) 1. .si文件 .si文件存储了段的元数据,主要涉及SegmentInfoFormat.java和Segmentinfo.java这 ...
- Lucene学习总结之三:Lucene的索引文件格式(1) 2014-06-25 14:15 1124人阅读 评论(0) 收藏
Lucene的索引里面存了些什么,如何存放的,也即Lucene的索引文件格式,是读懂Lucene源代码的一把钥匙. 当我们真正进入到Lucene源代码之中的时候,我们会发现: Lucene的索引过程, ...
- 《Python编程从0到1》笔记4——你分得清“索引和切片”吗?
Python为序列类型(sequence types)[1]提供了独特的索引(indexing)和切片(slicing)机制以访问序列的某个元素或某一部分. [1] 如list, tuple, ran ...
- spark机器学习从0到1特征变换-标签和索引的转化(十六)
一.原理 在机器学习处理过程中,为了方便相关算法的实现,经常需要把标签数据(一般是字符串)转化成整数索引,或是在计算结束后将整数索引还原为相应的标签. Spark ML 包中提供了几个相关的转换器 ...
- Parameter index out of range(1 > number of parameters, which is 0)参数索引超出范围
今天在写项目的过程中,有一个模块是做多选删除操作,通过servlet获得多选框的value组,然后执行sql操作.如下: 1 @RequestMapping( "/delteCouse.do ...
- 我的MYSQL学习心得(九) 索引
我的MYSQL学习心得(九) 索引 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) 数据类 ...
随机推荐
- PHP算法 《图》 之 理论基础
转载自:http://www.cnblogs.com/skywang12345/p/3691463.html Ⅰ 图的基本概念 1. 图的定义 定义:图(graph)是由一些点(vertex)和这些点 ...
- hdoj 2057
代码: #include <stdio.h>#include<string.h>int main(){ __int64 a,b,c; while(scanf("%I6 ...
- 【深度解析】Google第二代深度学习引擎TensorFlow开源
作者:王嘉俊 王婉婷 TensorFlow 是 Google 第二代深度学习系统,今天宣布完全开源.TensorFlow 是一种编写机器学习算法的界面,也可以编译执行机器学习算法的代码.使用 Tens ...
- Bridge 模式
Bridge 模式将抽象和行为划分开来,各自独立,但能动态的结合.在面向对象设计的基本概念中,对象这个概念实际是由属性和行为两个部分组成的,属性我们可以认为是一种静止的,是一种抽象,一般情况下,行为是 ...
- SGU 194. Reactor Cooling(无源汇有上下界的网络流)
时间限制:0.5s 空间限制:6M 题意: 显然就是求一个无源汇有上下界的网络流的可行流的问题 Solution: 没什么好说的,直接判定可行流,输出就好了 code /* 无汇源有上下界的网络流 * ...
- 寒假挑战PythonTip(一人一python)总结——算法是程序的灵魂,程序员的心法
2014年2月中旬,我上升到挑战python英雄榜第3名.这是我寒假修炼算法的成果之一.来一下总结吧! Linux的创始人Linus Torvalds在一次演讲中有一段涉及“什么才是优秀程序员 ...
- Linux内存点滴:用户进程内存空间
原文出处:PerfGeeks 经常使用top命令了解进程信息,其中包括内存方面的信息.命令top帮助文档是这么解释各个字段的.VIRT , Virtual Image (kb)RES, Residen ...
- @import————————css代码内部链接另外css
在css代码里这样可以链接另外的css @import url("style.css"); @import语法结构 @import + 空格+ url(CSS文件路径地址); ...
- ecshop--加载初始化文件
define('IN_ECS', true);require(dirname(__FILE__) . '/../../includes/init.php'); 在开头要加入这两句文件才可以访问数据库以 ...
- Python自动化运维之31、Tornado框架
Tornado 官网:http://www.tornadoweb.org/en/stable/ Tornado 是 FriendFeed 使用的可扩展的非阻塞式 web 服务器及其相关工具的开源版本. ...