- 在线时间
- 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-10069 r0 r5 [. |; k( V4 k( K$ ?; s1 j
* o- y& r, j) [7 x& T/ H& @ r在本地VC6.0下测试,得出正确结果, 为什么提交后总是Wrong Answer& U9 {- O8 P8 E- V
) y1 `8 T; a# e现将代码贴出,请帮忙看看:9 M/ D R9 z. X; B
 - #include <iostream>6 |& R6 Y1 ?- A8 l# u\\" d
- using namespace std;
- 2 f* I i% w! A
- #define PH 0) ^5 y: m0 H N3 v: d: \1 E* K\\" K
- #define EM 10 [, I# D0 v. T: J6 V5 X7 y
- #define IN 2
- 3 s+ @, F5 g% P$ B2 y) b, _\\" @
- int get_Top(int days, int kind);
- ; e2 B1 K+ z7 t0 l% x
- int triple(int ptop, int etop, int itop, int cur);
- 8 G& H$ |! \6 Y' V+ F
- bool is_Integer(float n);
- ' x6 ~: c. w' q( C; Z/ K
- int main()
- 5 d. a o: ~5 g( x
- {1 x ^, S$ \* O* }: e! x
- int ptop, etop, itop;
- ) R7 r0 |# ?: e' z8 }
- int pdays, edays, idays, curdays;
- ( y; t\\" Z2 @, A. K. Y
- int count =0;
- 6 }# ` Z\\" V: g' ~
- ( }4 H) C4 J1 n A( e, Y
- while(cin >> pdays >> edays >> idays >> curdays)
- ! @& c% |; v: o4 A$ a
- {
- 9 g! F# H1 B$ _9 H, w\\" Y
- if(pdays==edays&&pdays==idays&&pdays==curdays&&pdays==-1)5 K6 x7 i9 X( F7 f( b
- break;
- $ _, E K! R4 F+ M- d! ~4 S
- count++;0 f6 X v' ~; a$ j: J3 `- \( B
- ptop = get_Top(pdays,PH);
- + b& N1 n' r2 H% S, e8 a
- etop = get_Top(edays,EM);; b( k6 x0 X' j T$ z
- itop = get_Top(idays,IN);6 L. O1 J7 d( {
- cout<<"Case "<<count<<": "<<"the next triple peak occurs in "<<triple(ptop, etop, itop, curdays)<<" days.";
- ( T$ ?& N7 N, ~4 k
- }$ m) A/ b# H* W8 a& s( O
- & ]5 h O( B1 V) g8 y
- return 0;
- \\" Q& s& ^/ y4 y$ Z
- }2 I/ L- t7 C% o( [
- int get_Top(int days, int kind)5 p* u! Y ~4 d6 W7 A2 r4 K1 X3 Z
- {4 R% x( w0 h3 [! T% L+ u/ F
- switch(kind)
- A. s/ u, P9 j& J' _6 p' N9 E6 W
- {
- $ V2 h3 U* r* J( i) ~$ O
- case 0:: a# M% Q! u; g, ^! [
- return days%23; \5 {8 h, k* q& y `4 r o
- case 1:& F% v# q% k6 x& ^0 X1 @. ?/ l
- return days%28;3 s+ N# w$ R5 S' W- Y
- case 2:/ s( |5 _* O( P; }: B
- return days%33;
- 0 B2 P* [9 |0 P, Z7 W
- }
- }0 k: a: q% z( g7 @ _* F
- return 0;
- \\" @\\" `\\" {4 ?0 y* T4 r
- }
- - i* M) T8 w8 v% n$ b s, b% q
- 7 K' D( L: w\\" {( k: S
- int triple(int ptop, int etop, int itop, int cur)
- ) e+ m. K9 Z n, q# y2 _
- {% C% z$ C9 t- e7 A% _% X8 j9 X
- float x, y, z;7 i( U2 }$ {! H% B. V3 t9 c
- int m1 = etop-ptop-5,
- o! g* a\\" O2 D3 U% j( Q' Y
- m2 = itop-etop-5;, k/ Q\\" _9 s* p; w
- int temp = 0;/ ?5 ]2 U% f% L# D* @# J) m
- for(z=2; (itop+(z-1)*33) <= 21252; z++)
- % @; y% ^0 ?2 D) a4 n; _
- {6 Q7 ]\\" s# P5 I
- temp = m2 + 33*z;
- 2 p\\" \% Y; ]5 N8 C5 `
- y = (float)temp/28;: W5 H* R6 Q, S. Z
- x = (float)(m1+temp)/23;
- ! _# c: {& Z# [+ `0 q0 C
- if(x>0 && y>0 && is_Integer(x) && is_Integer(y))
- & c% w& |3 E: S6 B
- return itop + (z-1)*33 -cur;/ X; h( H2 g& H* w4 o+ l- C) P _
- }9 J. O# J# j8 T% c
- return 0;, t$ W3 V0 t3 E7 ~1 G2 W9 s# d) A: r
- }
- 5 m. _. e; H, j/ O/ g- N6 X% W) {
- ) t3 E+ D8 X- w
- bool is_Integer(float n)* I+ T& D( a4 g0 A\\" v
- {
- ; P# g2 m. T4 D. B# X' o
- if( (int)n - n ==0)
- / I9 M; e( o$ t- E
- return true;$ r& }0 S& @3 X# K! }0 E8 Y; C( s9 V
- else
- / B% l# N. f2 z+ _- k
- return false;
- 3 e9 R P* O& X7 z
- }+ h- r6 P' f! Y2 `! a$ e2 t1 f6 W
- , W) U3 e6 h- B+ y( q/ S5 B
) j L t, C: Y1 g# N
|
zan
|