- 在线时间
- 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
" C6 j8 s8 x' e7 _; z' B" q! C8 b, b. t* {. r3 f
在本地VC6.0下测试,得出正确结果, 为什么提交后总是Wrong Answer( q% h6 s" f* R7 V% r
+ {. }5 T; \) }* v
现将代码贴出,请帮忙看看:( e1 d# `3 o& }
 - #include <iostream>* {3 m- k* f1 M! W' C
- using namespace std;! w( _0 k$ O- o\\" N5 `- b
- #define PH 0
- \\" j. }) O4 L! ^! T
- #define EM 1
- 6 }# a: {) }9 w2 Q4 R& g# `
- #define IN 2: f) N0 N+ p$ S% l& ^7 z# }$ k
- int get_Top(int days, int kind);9 ?' G4 Q8 L; O\\" d: e( b' n
- int triple(int ptop, int etop, int itop, int cur);
- % U\\" T9 @7 t. f7 m+ w
- bool is_Integer(float n);5 u1 w' Q) G# D$ s% u
- int main()
- + ^' A6 D0 D: c H
- {1 e0 d( V1 G1 Q
- int ptop, etop, itop;
- 4 N) A& k! \2 f3 g4 R/ A. m
- int pdays, edays, idays, curdays;$ Z y* L8 A6 |- a8 h, J% b
- int count =0;' O+ u( p3 q# \8 j/ P+ v7 q
-
- . b# M: a7 K1 `, H# I) v
- while(cin >> pdays >> edays >> idays >> curdays)$ w' s( c1 l C4 U/ {; Y( b8 x w7 V
- {
- 2 j* p1 r1 d) K5 t1 M
- if(pdays==edays&&pdays==idays&&pdays==curdays&&pdays==-1)7 P$ @4 F! S& b' o
- break;1 M% d8 C5 d; E2 K, f e5 Y
- count++;
- ) Y: E5 s3 c+ } M2 ?& n. J
- ptop = get_Top(pdays,PH);4 w% O, E) w: K% u- |
- etop = get_Top(edays,EM);# x- Z0 N' @+ D$ Y5 A
- itop = get_Top(idays,IN);
- t; I- p n/ d+ I# m$ n
- cout<<"Case "<<count<<": "<<"the next triple peak occurs in "<<triple(ptop, etop, itop, curdays)<<" days.";2 O, v& j1 m1 s* n\\" j
- }
- ! a4 `! T* F8 a$ F\\" C1 r& }
-
- / O7 t3 ~: W* H2 R1 N1 P
- return 0;4 O7 Z& G) w$ F) K4 B( U U
- }) R0 |; f% g, I9 X' ~
- int get_Top(int days, int kind)
- ; x p# m# ]1 f' ]
- {
- ) Q! Z5 i3 {% M- y& `: d4 v
- switch(kind): L8 ^5 x; x& M- y0 \8 { c* ]
- {1 Z8 f: v$ M/ R/ G# m' g+ {
- case 0:0 W3 a7 n# J7 z. ?( T9 n* X# ]4 h
- return days%23;; d6 ?2 s: f S7 N, P. t% S; D
- case 1:% k3 k- l% `2 B# b3 ^5 Q' j6 ]5 Q( e! a N
- return days%28;
- & m7 @2 u4 ~: ? Z g% P
- case 2:
- 8 ?4 w. I' K) P: ?# f# S* q! X0 j
- return days%33;% T& d+ i7 ^& u6 s4 N% w( W5 d
- }
- # Z: N! P5 m2 }$ K
- return 0;
- 4 @3 k# h# X4 v' |$ H) d( U
- }
- 2 B9 |8 i& `; I8 L9 ~
- 1 ?- T% x+ M E# p+ n q7 X
- int triple(int ptop, int etop, int itop, int cur)8 l3 A( r% k( h' C
- {
- % F! U. F. k2 z% _/ ~! M7 I+ {
- float x, y, z;* ]8 o _ U! u' v5 a+ c
- int m1 = etop-ptop-5,
- $ N$ b5 g+ `# j
- m2 = itop-etop-5;
- & p5 G- i: I5 ^, w% O9 z0 a! ~7 ^
- int temp = 0;
- 7 f\\" @ ~1 J4 S- q
- for(z=2; (itop+(z-1)*33) <= 21252; z++)
- \\" F# Y# Z: \/ W4 ?- @. K9 h
- {
- % c# m+ L9 a5 p* g9 I) r
- temp = m2 + 33*z;
- : o! C( Q4 N: Q% i) a
- y = (float)temp/28;
- 3 {1 Y5 `& d/ o( c- y6 Z, U
- x = (float)(m1+temp)/23;
- . c( V1 h0 |9 u+ t$ y
- if(x>0 && y>0 && is_Integer(x) && is_Integer(y))2 B3 \* Y/ O' E\\" H8 g! M; ~- a% u* r
- return itop + (z-1)*33 -cur;0 |3 z9 V$ x: v0 |8 [2 ^
- }
- 6 n6 d$ x) H |% L) T
- return 0;
- 4 a/ _& E) V: g; S! h0 G( ]. S
- }
- % h& S, ` m) o+ x: S8 K) X
- / Q4 W; t) F8 y# x% O* k9 E
- bool is_Integer(float n)
- & }' M: V8 e+ a( `
- {$ x\\" n6 L: C) E; Q: E$ V$ ?
- if( (int)n - n ==0)# W2 H. s8 n$ \7 p, G( r
- return true;6 e2 i/ D9 B% E. G
- else
- % c\\" \/ T6 `( e' |' P- ~
- return false;
- 6 G3 { l\\" d; L1 I3 w) }/ ?
- }$ ?3 d7 U! w& E$ j; Q
- , M\\" ]* e/ t- ~; Z* I
* ~& H( C- ]/ n. y$ o' E6 k1 ] |
zan
|