- 在线时间
- 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
& \/ ~. e2 _/ J7 x X, `9 y6 _/ {% S3 R- Z# p' M0 M
在本地VC6.0下测试,得出正确结果, 为什么提交后总是Wrong Answer J4 l" O! a; y5 {4 J! ~( ?% S8 i
1 y P% u: @! Y4 ]6 W( D% U
现将代码贴出,请帮忙看看:
; B% o5 I! ?3 m3 a( s! f - #include <iostream>
- 6 ?, Y: E2 O7 M9 o( O0 I
- using namespace std;
- 6 \( _' s# t: \0 l% L
- #define PH 02 ]- X/ R$ h2 B W5 `2 v
- #define EM 1! o: J w6 I2 n7 h' C
- #define IN 2
- 7 ]9 M0 ?2 n* H\\" t+ I; ?, e/ o6 o
- int get_Top(int days, int kind);; v# P, k4 b9 @- e7 N3 g
- int triple(int ptop, int etop, int itop, int cur);
- & N+ o6 e' B \7 m. w0 i
- bool is_Integer(float n);: l- d0 r% w, Y& k
- int main()$ {, f+ H7 }4 a Z+ W8 H
- {7 z4 o& ^8 |$ D5 a
- int ptop, etop, itop;
- * [$ u: F- h$ L$ I( P
- int pdays, edays, idays, curdays;
- & w$ t! n% I3 p
- int count =0;6 M6 C8 g, @9 Y& |% S1 I
-
- , G+ i' d6 R' ?- z- Y
- while(cin >> pdays >> edays >> idays >> curdays)# A( H0 v5 h- \. _2 D
- {1 I7 J. ?2 t% F6 T) s; }0 s! f
- if(pdays==edays&&pdays==idays&&pdays==curdays&&pdays==-1)
- 9 }* }) `4 x' U! }4 I
- break;
- % d1 k4 Y$ O8 c7 Y1 x2 T t2 X\\" T2 G: m
- count++;
- + K! c' l% O% w8 d
- ptop = get_Top(pdays,PH);
- ; @% O% Z+ I9 G( f* u0 o
- etop = get_Top(edays,EM);5 [1 c F3 J4 ]9 t3 q
- itop = get_Top(idays,IN);
- 6 x$ ]( O! H/ H8 K' v\\" ]
- cout<<"Case "<<count<<": "<<"the next triple peak occurs in "<<triple(ptop, etop, itop, curdays)<<" days.";
- - H) P) P) ^3 S6 w
- }
- + K# `5 R1 t) u
-
- & a3 d M6 t* l/ S: f! f d z- F% ~5 S( |
- return 0;/ t/ Q, t\\" _( i' h1 w9 n
- }\\" y4 X h8 e8 I$ r1 ?7 a
- int get_Top(int days, int kind)' E( @9 D) h& m8 M+ a' R
- {0 D5 w# G0 h$ O3 ~* i, \
- switch(kind)
- ' o# a# \\\" O3 D# g\\" V& E
- {
- 7 J1 O* z/ B6 @* ]
- case 0:
- / X# Y( }/ D- F M, e- t
- return days%23;
- ( J. Q& d/ H h+ J5 i
- case 1:
- + d. G- I: C% d5 y( Q N: B. n8 d- d
- return days%28;
- 4 ?7 I7 r& X5 g% x- W; ?8 L\\" k
- case 2:- q. l* X# Z2 Q
- return days%33;
- 0 N& P% J; O' G. ?6 X( c
- }
- \\" \% K+ s% Q2 W9 o5 y! Q
- return 0;
- \\" E. j! b3 c4 E
- }6 v8 @. A\\" P2 O8 g0 O5 m
- \\" h& ]8 D* h3 ]( `1 e. L& K
- int triple(int ptop, int etop, int itop, int cur)
- 1 x) n8 `( a6 D9 P+ ^& O' b
- {/ q0 H0 c( ]# T) x* {\\" j- \
- float x, y, z;
- % l8 Q4 c Z W7 q2 M' Z
- int m1 = etop-ptop-5,
- ; D7 E% _7 e+ H\\" _( B\\" m* G& T
- m2 = itop-etop-5;& r* h3 y+ F/ g7 ^9 L% ]! g% E2 J
- int temp = 0;
- \\" @2 D' [. q, O( y( b
- for(z=2; (itop+(z-1)*33) <= 21252; z++)& V5 S7 c( v( ~( m: n7 f
- {
- 1 t. u, r1 b9 g( Q* V( T
- temp = m2 + 33*z;, S7 U, _9 I2 }7 \
- y = (float)temp/28;2 X8 }\\" Z6 E) U+ e# u9 }4 R
- x = (float)(m1+temp)/23;
- 9 }3 A2 `5 e0 Z$ Y
- if(x>0 && y>0 && is_Integer(x) && is_Integer(y))$ l$ u9 Y\\" {6 {7 n- y+ O# k- q
- return itop + (z-1)*33 -cur;
- + S i3 v- m; J
- }% }) |\\" c4 i! X+ c$ h
- return 0;( I3 x4 |7 i2 ^9 ?3 [4 S2 e% v# W
- }
- \\" G' u }3 F- q
- 7 \( f% Y$ k2 [2 W) F4 u
- bool is_Integer(float n)/ @2 D$ W$ |9 h& I* k: |
- {
- + ]) v+ U( Y A$ w4 u& K9 ` s
- if( (int)n - n ==0)
- 1 g- z$ z* K5 a( u9 A8 B
- return true;
- + h& T' w9 f4 e4 R
- else- d4 l1 z+ n/ I8 S/ f
- return false;
- % W7 Z# B, g, J g$ R; Q1 w
- }! x$ E% A\\" m6 t5 a) r
- 3 F' {2 T# |5 _3 ^
' E j. L! s z, o* X# M |
zan
|