- 在线时间
- 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" q! q# h4 H: l4 t$ b
$ e' _* ?" R4 q: ?' A7 _% O在本地VC6.0下测试,得出正确结果, 为什么提交后总是Wrong Answer
7 H+ y+ X6 y$ u1 w0 [) Q
7 C8 A7 A' v; G% L. H现将代码贴出,请帮忙看看:
( X1 z9 R j8 |) s) c& N8 D0 M - #include <iostream>
- % {\\" j/ p! i1 Z. n& d
- using namespace std;$ D& _+ j* B\\" A3 B# I: S
- #define PH 01 R0 K0 A7 y5 a2 L ?6 G\\" y0 I/ I4 v: R
- #define EM 1
- ! F1 ~- T0 u. U a\\" ?& K/ _
- #define IN 2! o3 g, n) m/ v1 x3 W. s4 A
- int get_Top(int days, int kind);
- $ i k) [9 L\\" O9 L\\" T2 ?+ G# ~9 O
- int triple(int ptop, int etop, int itop, int cur);
- 8 ?4 n5 X2 f4 f+ n- T$ E\\" C
- bool is_Integer(float n);8 E' |1 t/ ~) u- S
- int main() B* l h# a, `& q
- {8 _! F$ v1 ?* ?* L
- int ptop, etop, itop;/ x; U\\" |% O% f0 g
- int pdays, edays, idays, curdays;
- , J5 b6 d! l- F9 }. h
- int count =0;
- , ?8 B% ^3 ~* j0 \3 B n3 _
-
- 8 c1 s: n6 J1 d3 l, ?* _
- while(cin >> pdays >> edays >> idays >> curdays)
- . \$ e/ a$ e1 i9 E/ p
- {
- & V! y; J) @/ q! D, M: ]
- if(pdays==edays&&pdays==idays&&pdays==curdays&&pdays==-1), g- q7 v: L# ?$ w3 I
- break;
- 7 i7 G\\" @- P% |9 Y+ y
- count++;
- $ J. g6 V4 l2 Z% F1 [0 p* d! w
- ptop = get_Top(pdays,PH);% J& E _( b8 `9 @# l, c% ?
- etop = get_Top(edays,EM);' L' F! _, A3 W0 ]; M! m
- itop = get_Top(idays,IN);) U) D$ V4 A& S2 }, T/ F: D( Y
- cout<<"Case "<<count<<": "<<"the next triple peak occurs in "<<triple(ptop, etop, itop, curdays)<<" days.";
- 9 G B0 k& ?; C) R# I: W7 S! s/ w
- }0 J! o A( ?$ F7 K; p
- 6 W( l, T6 z |
- return 0;5 z6 N. Z/ i m$ R
- }
- 8 e, U5 e7 j- B9 e\\" X2 ^
- int get_Top(int days, int kind)) q# f2 x8 A9 T ^
- {
- ) N0 U6 R' T. Z2 w' h
- switch(kind)1 A& E1 z. [4 X4 ~5 }$ s
- {
- - |1 q$ @& w5 U$ [' h W
- case 0:) `2 ?2 J. l& P' `* Q
- return days%23;
- , n& f\\" Q# {9 [2 H0 Z9 J. d
- case 1: i6 Q: b! L; t6 \9 ]
- return days%28;
- / {, N8 P3 E4 s) t: A. ~# h1 j
- case 2:
- 0 }- }2 q. E$ i, J\\" y4 Q
- return days%33;
- % n+ [% E% o/ x- ]! ~. G- x
- }2 c+ B1 C: H& }4 w
- return 0;$ E\\" h1 }5 r+ B! X- { o+ I( q
- }) p2 v5 w H N. j$ T) B! |. ~! Q+ U
- ( s2 j- K+ a2 P5 _4 Q* _9 O
- int triple(int ptop, int etop, int itop, int cur). k7 O5 v( X8 g0 N) Q B) V; _+ C5 Z
- {
- ; ?( e; B X, R5 }9 V. ^5 P4 R
- float x, y, z;
- , g: U; m3 M\\" x% q* S, B& V
- int m1 = etop-ptop-5,' | G1 M v1 o. X v& v9 {
- m2 = itop-etop-5;# L- ?) q. x7 C% p$ G: x- G7 I
- int temp = 0;4 m, o8 O! R! g% r3 s5 m
- for(z=2; (itop+(z-1)*33) <= 21252; z++)
- 8 B0 m4 |' o# n% u+ c: i
- {
- 6 ~& E3 k6 N5 ~
- temp = m2 + 33*z;
- / F& B\\" _; {& z' p: G4 @ u. S a
- y = (float)temp/28;& }/ t; k& G5 k$ v- a
- x = (float)(m1+temp)/23;
- / l7 ~3 N* B: f) o% h$ A6 F; N
- if(x>0 && y>0 && is_Integer(x) && is_Integer(y))\\" {1 c9 h1 r8 V7 U+ C3 l8 U3 s
- return itop + (z-1)*33 -cur;
- ! n# r0 \4 r+ Y0 }, n; Y
- }- V6 k2 n4 r/ X! y
- return 0;
- + F% ~- J9 i\\" Y+ T; q5 G5 A
- }7 i+ F7 Q$ x7 U, [5 ]: c\\" A
- : {3 n4 D- _2 X( m: x/ w7 |
- bool is_Integer(float n)
- 5 s& y. N, Z% w, C/ Y9 ~
- {
- : p* U5 m+ l: T: D
- if( (int)n - n ==0)+ d: f# h; W9 O/ _, i& f
- return true;, ^\\" {! M2 e4 |\\" O7 p4 ?
- else
- ) {\\" e s- N! f& A$ s
- return false;6 Y. O* K\\" ]7 \( q
- }
- 8 G) G3 u) a\\" \% a) h7 V
- & T\\" F3 M& K6 e. U2 u: X; D
( V& E+ L" Q: _6 T |
zan
|