博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
USACO 2.2 Runaround Numbers
阅读量:4598 次
发布时间:2019-06-09

本文共 1614 字,大约阅读时间需要 5 分钟。

TASK: lamps
LANG: C++
Compiling...
Compile: OK
Executing...
   Test 1: TEST OK [0.000 secs, 3032 KB]
   Test 2: TEST OK [0.000 secs, 3032 KB]
   Test 3: TEST OK [0.000 secs, 3032 KB]
   Test 4: TEST OK [0.000 secs, 3032 KB]
   Test 5: TEST OK [0.000 secs, 3032 KB]
   Test 6: TEST OK [0.000 secs, 3032 KB]
   Test 7: TEST OK [0.000 secs, 3032 KB]
   Test 8: TEST OK [0.000 secs, 3032 KB]
All tests OK.
 
1
/*
2
PROG: runround
3
ID: jiafeim1
4
LANG: C++
5
*/
6
7
8
#include
<
iostream
>
9
#include
<
fstream
>
10
11
using
namespace
std;
12
13
unsigned
long
res;
14
15
unsigned
long
decX[
11
]
=
{
1
,
10
,
100
,
1000
,
10000
,
100000
,
1000000
,
10000000
,
100000000
};
16
bool
check(unsigned
long
num)
17
{
18
bool
haveDo[
11
]
=
{
false
};
19
bool
haveDoNum[
11
]
=
{
false
};
20
int
l
=
0
;
21
unsigned
long
temL
=
num;
22
while
(temL)
23
{
24
if
(temL
%
10
==
0
)
return
false
;
25
++
l;
26
temL
/=
10
;
27
28
}
29
unsigned
long
cur
=
0
;
30
unsigned
long
temp;
31
32
for
(
int
now
=
1
;now
<=
l;
++
now)
33
{
34
if
(haveDo[cur])
return
false
;
35
temp
=
(num
/
decX[l
-
cur
-
1
])
%
10
;
36
if
(haveDoNum[temp])
return
false
;
37
haveDo[cur]
=
true
;
38
haveDoNum[temp]
=
true
;
39
cur
=
(temp
+
cur)
%
l;
40
}
41
if
(cur
!=
0
)
return
false
;
42
return
true
;
43
}
44
45
int
main()
46
{
47
std::ifstream fin(
"
runround.in
"
);
48
std::ofstream fout(
"
runround.out
"
);
49
50
int
n;
51
52
fin
>>
n;
53
for
(res
=
n
+
1
;;
++
res)
54
{
55
if
(check(res))
56
{
57
fout
<<
res
<<
endl;
58
break
;
59
}
60
61
}
62
63
fin.close();
64
fout.close();
65
66
}

转载于:https://www.cnblogs.com/huanyan/archive/2011/05/05/USACO_Runaround_Numbers.html

你可能感兴趣的文章
IE10 招贤纳意问题整理文章-安装卸载、功能设置篇
查看>>
joomla处境堪忧
查看>>
Jquery-AJAX
查看>>
python 在windows环境下 压缩文件
查看>>
CSS 动画总结
查看>>
mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by
查看>>
LeetCode55 Jump Game
查看>>
poj 3764 The xor-longest Path (01 Trie)
查看>>
预备作业01
查看>>
【Spark】Spark-Redis连接池
查看>>
【云计算】使用supervisor管理Docker多进程-ntpd+uwsgi+nginx示例最佳实践
查看>>
Ubuntu16.04下配置ssh免密登录
查看>>
实验二 2
查看>>
will-change属性
查看>>
android学习笔记54——ContentProvider
查看>>
Unity3d android开发之触摸操作识别-双击,滑动去噪处理
查看>>
Custom view * is not using the 2- or 3-argument View constructors; XML attributes will not work
查看>>
模型选择准则
查看>>
安卓动态增加按钮
查看>>
iOS7程序后台运行
查看>>