zoj 1745 又是简单题
2010-08-03 15:16
176 查看
////////////////////////////////////////////////////////
// ZOJ:1745
// 本题出现最多的就是输出格式错误的问题,被题目调戏了
///////////////////////////////////////////////////////
#include "stdio.h"
#include "math.h"
int main(void)
{
int cookiepos[500] = {0};
int pos[500][500] = {0};
int prepos;
int dis;
int i = 0;
int k;
int m;
int x, y;
while (scanf("%d", &cookiepos[i]))
{
if (cookiepos[i] >= 5280)
{
break;
}
k = 0;
while (scanf("%d", &pos[i][k]))
{
if (cookiepos[i] == pos[i][k])
{
break;
}
k++;
}
i++;
}
m = i;
x = 0;
while (m-- > 0)
{
y = 0;
dis = abs(0 - cookiepos[x]);
prepos = 0;
while (pos[x][y] != cookiepos[x])
{
if (abs(pos[x][y] - cookiepos[x]) > dis)
{
printf("Moving from %d to %d: colder./n", prepos, pos[x][y]);
prepos = pos[x][y];
dis = abs(pos[x][y] - cookiepos[x]);
}
else if (abs(pos[x][y] - cookiepos[x]) < dis)
{
printf("Moving from %d to %d: warmer./n", prepos, pos[x][y]);
prepos = pos[x][y];
dis = abs(pos[x][y] - cookiepos[x]);
}
else if (abs(pos[x][y] - cookiepos[x]) == dis)
{
printf("Moving from %d to %d: same./n", prepos, pos[x][y]);
prepos = pos[x][y];
dis = abs(pos[x][y] - cookiepos[x]);
}
y++;
}
printf("Moving from %d to %d: found it!/n", prepos, pos[x][y]);
if (m >= 1)
{
printf("/n");
}
x++;
}
return 0;
}
// ZOJ:1745
// 本题出现最多的就是输出格式错误的问题,被题目调戏了
///////////////////////////////////////////////////////
#include "stdio.h"
#include "math.h"
int main(void)
{
int cookiepos[500] = {0};
int pos[500][500] = {0};
int prepos;
int dis;
int i = 0;
int k;
int m;
int x, y;
while (scanf("%d", &cookiepos[i]))
{
if (cookiepos[i] >= 5280)
{
break;
}
k = 0;
while (scanf("%d", &pos[i][k]))
{
if (cookiepos[i] == pos[i][k])
{
break;
}
k++;
}
i++;
}
m = i;
x = 0;
while (m-- > 0)
{
y = 0;
dis = abs(0 - cookiepos[x]);
prepos = 0;
while (pos[x][y] != cookiepos[x])
{
if (abs(pos[x][y] - cookiepos[x]) > dis)
{
printf("Moving from %d to %d: colder./n", prepos, pos[x][y]);
prepos = pos[x][y];
dis = abs(pos[x][y] - cookiepos[x]);
}
else if (abs(pos[x][y] - cookiepos[x]) < dis)
{
printf("Moving from %d to %d: warmer./n", prepos, pos[x][y]);
prepos = pos[x][y];
dis = abs(pos[x][y] - cookiepos[x]);
}
else if (abs(pos[x][y] - cookiepos[x]) == dis)
{
printf("Moving from %d to %d: same./n", prepos, pos[x][y]);
prepos = pos[x][y];
dis = abs(pos[x][y] - cookiepos[x]);
}
y++;
}
printf("Moving from %d to %d: found it!/n", prepos, pos[x][y]);
if (m >= 1)
{
printf("/n");
}
x++;
}
return 0;
}
相关文章推荐
- ZOJ 2207 听说是简单题,结果我是被折磨得半死写出来的代码还特丑
- zoj 1745 Tree Recovery
- ZOJ 1694 Shredding Company(简单DFS)
- ZOJ 3542 2011大连现场赛D题(简单模拟)
- ZOJ 3542 2011大连现场赛D题(简单模拟)
- ZOJ 3682 简单dp 背包
- zoj 1884 简单 键盘 字符 处理
- ZOJ 1608 Two Circles and a Rectangle(简单计算几何)
- zoj 3714 Java Beans(简单题)
- ZOJ 2812 Quicksum (简单的求和~水)
- 2014牡丹江网络预选赛I题(字符串hash+简单DP)zoj3817
- ZOJ 1101 Gamblers (简单搜索)
- zoj 1383 Binary Numbers&&zoj 1491 Climbing Worm(简单)
- ZOJ 简单题集合(四)
- 简单BFS ZOJ 1649 Rescue
- ZOJ 2100 Seeding(简单DFS)
- 简单概率dp(期望)-zoj-3640-Help Me Escape
- ZOJ 3167(大数乘小数的简单应用)
- ZOJ 3778 Talented Chef(找规律,模拟计算,11届ACM省赛,简单)
- ZOJ 1745 Are We There Yet?