- 在线时间
- 0 小时
- 最后登录
- 2010-11-12
- 注册时间
- 2010-8-27
- 听众数
- 3
- 收听数
- 0
- 能力
- 0 分
- 体力
- 46 点
- 威望
- 0 点
- 阅读权限
- 20
- 积分
- 16
- 相册
- 0
- 日志
- 0
- 记录
- 0
- 帖子
- 5
- 主题
- 2
- 精华
- 0
- 分享
- 0
- 好友
- 1
升级   11.58% 该用户从未签到
 |
POJ-1006 j( M" o8 ]+ F* {7 l) V! { M
. J7 d& K+ E3 c5 H" L
在本地VC6.0下测试,得出正确结果, 为什么提交后总是Wrong Answer+ |, S2 t9 M/ x c, A
) T! X5 t) }# ^2 d0 C
现将代码贴出,请帮忙看看:+ r$ n7 S) v. t ~! o1 y/ L, t
 - #include <iostream>
- / p- ?# A: h6 B+ L2 l d9 b
- using namespace std;+ ]) G! W8 q! C$ b/ I4 I% l0 {
- #define PH 01 `\\" q. Y3 L\\" K, p
- #define EM 1
- & v* h* |6 j! R3 `\\" ]1 [; @. B
- #define IN 2
- & r# w, @: `& C$ O5 W; n l
- int get_Top(int days, int kind);' q L* P M! K0 t/ }
- int triple(int ptop, int etop, int itop, int cur);& s+ u4 ]\\" Y\\" C1 f9 U1 i
- bool is_Integer(float n);% {( y2 i' S) n1 g! i( }\\" g; m
- int main()
- 4 T- h* _. P$ N( S
- {
- 5 V( D7 D+ |. z0 R) D% Z5 o
- int ptop, etop, itop; a. V7 e- F. z7 d' m' C) U) X7 g6 N
- int pdays, edays, idays, curdays;
- Z# m& S5 x: c4 F* y
- int count =0;
- 2 _2 R. Q$ q+ x( ~- }. ~. b3 c
-
- ! ~. r2 C; G; X' S9 `
- while(cin >> pdays >> edays >> idays >> curdays)
- : N3 j' O* ]3 D; R, G; S
- {( h* j( v0 E4 ~. r
- if(pdays==edays&&pdays==idays&&pdays==curdays&&pdays==-1)
- ; ]. T4 N, E& S: G* J
- break;8 o+ G8 q2 s; J/ } X
- count++;0 q+ @& T+ e- u5 z8 E( c; ^
- ptop = get_Top(pdays,PH);
- 9 i: u, d/ g/ a8 h\\" D9 v
- etop = get_Top(edays,EM);
- 3 E# Q( ?, ~% i\\" `\\" h2 I
- itop = get_Top(idays,IN);8 ], `! w4 Y! X9 J7 `( I; H; T
- cout<<"Case "<<count<<": "<<"the next triple peak occurs in "<<triple(ptop, etop, itop, curdays)<<" days.";
- ; j. p: B! D F' l- Y6 R
- }8 r3 T2 r/ I2 g6 b8 h2 I
- 4 u3 W. k7 r\\" O0 H& v; [- I% s
- return 0;
- - G\\" k$ o' A l
- }; n/ Y5 q1 _5 d( [0 p' x
- int get_Top(int days, int kind)
- \\" c4 H% F* x& y8 C\\" S
- {
- # Z3 e6 v3 }2 l/ G6 h1 c7 q
- switch(kind)
- - \$ _: G8 W2 c! K1 k( g
- {
- ' u4 v5 @% q$ W6 g5 J
- case 0:5 d% o* }, x2 M7 f; u* T
- return days%23;
- \\" k! Y0 |- h2 {, l, m9 Z, P
- case 1:5 B: e& F! N* D1 z$ U$ I3 K
- return days%28;$ Z, f+ b0 g) } L- `
- case 2:' C\\" d- j6 F% q, M
- return days%33;6 F( o1 o0 L* Q+ H! w! q1 Q
- }0 G( X7 S- }1 l, m# z# e6 q
- return 0;
- \\" l1 i0 ]6 L8 o3 u$ r
- }, S z# _ w7 @. e
- 6 `( b* M\\" h/ L. y7 n4 B+ i
- int triple(int ptop, int etop, int itop, int cur); I6 [9 Y$ P# I6 n$ b7 W! [5 r
- {
- ' O, N( t. Y. r6 ~. K
- float x, y, z;
- & L\\" S; `+ S2 r\\" Q% p
- int m1 = etop-ptop-5,/ M9 ], x/ m5 S+ Y4 z
- m2 = itop-etop-5;# C# o% `: G/ t Y\\" E
- int temp = 0;5 A9 H0 L4 F\\" D- \: u9 n
- for(z=2; (itop+(z-1)*33) <= 21252; z++)
- ) E* I) s9 q4 @+ l
- {* P4 s- R4 g+ u' U4 x\\" W- W5 D
- temp = m2 + 33*z;7 u6 W/ c- z% s9 s\\" h# L
- y = (float)temp/28;7 X# V5 A( ~3 C( h' M
- x = (float)(m1+temp)/23;$ K9 [4 T, P9 z( P# [- T$ L
- if(x>0 && y>0 && is_Integer(x) && is_Integer(y))
- % {7 y# c, `3 s4 d
- return itop + (z-1)*33 -cur;
- % g1 O* S; c$ p
- }9 M: f7 d& j; ?& r' Y& q1 O: t
- return 0;
- $ o- I3 h4 I) l\\" [/ }\\" X
- }
- \\" S* [% Y' t( _4 _7 ^
- 7 }, H6 s: Q5 ]! t\\" |: N7 g9 y9 [
- bool is_Integer(float n)
- 1 [# O+ U4 N) y4 K
- {
- % e\\" T3 ?) x C\\" {! \: K8 b
- if( (int)n - n ==0)9 G M4 o) A% b, e' l2 [
- return true;. ]( `* [( ~) [- f! u% d
- else. F% P! @1 N. V9 z. @
- return false;
- 6 r4 w. q7 I. d6 S
- }
- 4 v0 j, y. y; h) n7 J
- 6 C2 g2 i9 o. Z2 C) E& M
) C, ]5 Q; Q: Q% r! G; z$ z. \
|
zan
|