- 在线时间
- 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
$ ]3 G. Q, W1 \* a' i% v% p1 F+ L z; t: n8 o
在本地VC6.0下测试,得出正确结果, 为什么提交后总是Wrong Answer: ~- s# o+ H: Q& K/ Q ^# D
( K! [8 O& i3 h9 S; H
现将代码贴出,请帮忙看看:+ f2 W3 C9 p- c
 - #include <iostream>4 q1 f& O# { k
- using namespace std;: S* B7 a. s$ y4 z; P6 v\\" Y3 u- I
- #define PH 0
- ; o# b2 J. V4 {3 t
- #define EM 1) C( d) g$ U& U9 c$ A0 T. h\\" ?
- #define IN 20 m3 p4 ?3 |\\" m; L, k
- int get_Top(int days, int kind);
- * A; Y; l5 ^3 l9 M
- int triple(int ptop, int etop, int itop, int cur);3 ^3 s0 J( V+ `8 K
- bool is_Integer(float n);; A1 V4 Z; U3 A% S3 {6 x+ ^
- int main() E+ ^# t; X s. V. Z* v( K1 l$ y
- {- ]1 x% v% D* C( n L# H
- int ptop, etop, itop;
- + y2 p6 v3 Q s' `
- int pdays, edays, idays, curdays;
- , y; }5 I9 b1 u( h( B' g# }0 V6 |6 j1 Z
- int count =0;9 A0 I% h p3 c8 p. i0 N6 ^
- + y: R6 O; G# A\\" X K1 t* s, V
- while(cin >> pdays >> edays >> idays >> curdays)
- 7 U( K; _( \ p- l4 w5 |
- {
- / E+ O9 F0 E7 y |- E2 f; v
- if(pdays==edays&&pdays==idays&&pdays==curdays&&pdays==-1)
- & F7 z: V# \3 h! W' [2 K5 Z
- break;
- 2 f8 |. r- e7 A! i* N
- count++;
- \\" ?0 @& r' n# @: A# d0 J& b* V
- ptop = get_Top(pdays,PH);
- 0 }9 e7 j9 }7 |\\" c+ R, C# U$ O% T
- etop = get_Top(edays,EM);
- + D% {0 n/ _5 F
- itop = get_Top(idays,IN);8 e. p! w0 d5 A0 p( N
- cout<<"Case "<<count<<": "<<"the next triple peak occurs in "<<triple(ptop, etop, itop, curdays)<<" days.";
- ! |3 C, U }# m1 R8 w
- }$ Y) s8 D. q; Z4 F7 n8 S
-
- 6 V+ V1 o$ ]. o0 H/ K
- return 0;$ K$ p( F; g# C& t$ F+ R* G) `
- }
- 1 ?! R4 b1 B2 I6 k& x
- int get_Top(int days, int kind)
- 5 s) e' ]$ S% r\\" h. m
- {
- ( `+ z$ t: u8 z' i6 a: K. L1 S
- switch(kind)
- - H1 t% l; }( H+ q
- {\\" \/ O) b3 {8 X' s! _# O
- case 0:1 Y; p3 y( y% S8 N\\" s7 y
- return days%23;- L$ c* G4 s8 ]7 J
- case 1:
- \\" T: n+ l, w8 h# h. o
- return days%28;
- 8 `# @( b# s9 \, d W
- case 2:1 ?0 i+ e7 D( O6 m& h' n; K
- return days%33;- Y) x7 c4 K* u% f
- }' q4 m: @, t* \+ D$ s; o
- return 0;
- - l. y6 O5 T\\" ?; ]# f
- }
- 6 d0 `( i$ A5 d6 i% k; c* A$ X
- 9 a\\" R9 a( k2 U+ F, r
- int triple(int ptop, int etop, int itop, int cur)
- 2 @/ ~; n1 Y4 } u( `8 T
- {
- 3 V! o& w3 v* f& J7 o
- float x, y, z;1 j% u\\" V* ?: {3 h0 q. C* Q* ]8 g
- int m1 = etop-ptop-5,
- 5 h( a/ t0 u1 _# y# d% I
- m2 = itop-etop-5;
- ( n: S# ~7 R3 I5 }5 m, X) i& q
- int temp = 0;8 a' x7 F ]+ R& d. g
- for(z=2; (itop+(z-1)*33) <= 21252; z++)
- / Y1 }\\" n8 q4 ^$ G2 [\\" o
- {2 _$ `# U8 {! m @\\" o: b
- temp = m2 + 33*z;
- - R# x _0 I S
- y = (float)temp/28;
- ( j/ a' X, A) p$ w
- x = (float)(m1+temp)/23;& I3 g) J! P1 K8 q; E
- if(x>0 && y>0 && is_Integer(x) && is_Integer(y))' B3 A( T( c3 C0 `. _2 ?
- return itop + (z-1)*33 -cur;- B! J9 M6 Z& {5 H8 Q% S& i- z
- }\\" d. a/ S1 j! }+ c+ w
- return 0;/ i2 O) o+ K6 S9 ]
- }
- + R) \8 P% N& k6 @' F+ |
- 5 `- Z: Q' }2 h4 ~5 u& P
- bool is_Integer(float n)
- \\" {7 B( a) O& W) Q7 n\\" z
- {2 ^7 i) }/ A5 Y% E+ f2 s3 x' g% b
- if( (int)n - n ==0)1 a8 f& u/ H1 I: [
- return true;
- A# X7 l a( N8 i9 t$ `
- else
- ' e3 ~7 F4 s8 }6 V) s6 e$ I' }& ^
- return false;
- 7 Y X9 z4 F; v. p\\" e- d: V# C- k
- }
- ' i. ~& P7 i( C9 A5 ]: r7 S9 e' f
- ) W; K, [- E3 r* h0 g0 j0 V\\" F* q
$ |0 Q4 t/ B% u3 m, J: m |
zan
|