- 在线时间
- 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( j7 y- n; b' Q/ i& v
9 f6 M3 t- }# W3 v6 p
在本地VC6.0下测试,得出正确结果, 为什么提交后总是Wrong Answer7 u; A. Q+ w; E& t' j
' f% ^; F9 q8 }# g& u7 J4 s" o现将代码贴出,请帮忙看看: d! ?0 s! O7 t
 - #include <iostream>
- % f1 i, @5 r0 h7 t- H
- using namespace std;
- 4 ^, g! ~7 s& }7 g1 d5 H# P\\" j3 n
- #define PH 0
- 2 z) x' J. ?0 z, R$ B& Y
- #define EM 1, b% d% E5 e0 B+ Y8 b2 ?
- #define IN 2
- 4 x$ M! t: W( s\\" n9 R
- int get_Top(int days, int kind);
- ( b: \; ^+ |; n& y
- int triple(int ptop, int etop, int itop, int cur);) _+ l% i- q; |: l& V- r
- bool is_Integer(float n);* R+ |. Q3 I$ W( [
- int main()
- 2 l* S } o( ^, [
- {
- - O) V: g6 N( k6 E4 s) w
- int ptop, etop, itop;- j- E+ }6 }# A. M- j
- int pdays, edays, idays, curdays;. i: ^' d# A4 [7 d
- int count =0;. j! z& q$ I: _7 J0 F) V4 K
- 6 V3 @6 j& c3 I. G( z, m; ~6 `
- while(cin >> pdays >> edays >> idays >> curdays) J% h5 U6 S B. k9 r+ e/ T
- {
- $ Q: ]- U, ]4 V7 w) u& {& D& O2 a9 K& Y
- if(pdays==edays&&pdays==idays&&pdays==curdays&&pdays==-1)0 Z6 D' p( H' y3 X7 D9 y% c4 P
- break;
- ; r; v4 j6 R( {6 W
- count++;2 E, \3 s( w% ~$ v4 h9 S9 @2 A
- ptop = get_Top(pdays,PH);2 O3 t2 f& Q0 B6 N5 w8 _) j0 U
- etop = get_Top(edays,EM);
- $ Z% G$ i+ S8 {+ Q+ v
- itop = get_Top(idays,IN);
- s: A. A8 T2 ` c0 ^3 o
- cout<<"Case "<<count<<": "<<"the next triple peak occurs in "<<triple(ptop, etop, itop, curdays)<<" days.";6 m; C/ f! ^- S- w) k
- }& M% Y2 t' g p6 s: s
-
- 8 N# X3 V$ N7 n, v
- return 0;9 o! E' ^) Y! c2 L+ Q: P
- }
- \\" x) s: z7 q b% W, t2 W& o
- int get_Top(int days, int kind)
- 4 ]8 P. ]# C1 n* X1 F% A
- {
- ; u4 z4 t5 d) y2 Z8 w) B1 C
- switch(kind) |' ` Z/ V+ @% h9 r' t3 ]
- {\\" ]! Z\\" F5 v- ^- e4 x% E) j1 k
- case 0:
- 1 G$ ]$ U3 \4 \1 I$ h6 x; O
- return days%23;3 P) y; {6 g' [4 S! Z\\" X
- case 1:- M- f3 k* q x\\" n7 ~
- return days%28;, P0 E2 o\\" y$ T: C0 I
- case 2:
- \\" n$ v, c0 ]) s; o
- return days%33;5 {# f/ q4 G. z\\" s
- }
- , F# @% @8 S/ O& k- R
- return 0;9 _( [# x8 l5 z2 P% O; Q& w- E
- }
- ; k8 L k\\" G; Y0 i7 x
- & Q5 N8 N/ c* u, j. y5 W8 q
- int triple(int ptop, int etop, int itop, int cur)
- & L9 o; l# S/ A3 \/ ]/ k
- {
- & [. j, X\\" v* ^1 O# K. a
- float x, y, z;1 h2 d\\" ^ L; c9 w( F
- int m1 = etop-ptop-5,: N% t3 R2 ]9 {+ @% c
- m2 = itop-etop-5;
- 4 P ]5 ?) p9 y ?9 y- C7 x
- int temp = 0;3 O |/ \8 E; {5 h2 i4 n
- for(z=2; (itop+(z-1)*33) <= 21252; z++); r8 V. c0 T2 f6 f$ P, N
- {$ K9 p1 H- C0 l; x$ ?
- temp = m2 + 33*z;1 d3 O2 I+ n$ F
- y = (float)temp/28;
- 5 s7 `& Y% N+ p/ ~# F! \! c- P
- x = (float)(m1+temp)/23;
- ! V6 |# F4 h- t# {\\" L/ i1 L( Z
- if(x>0 && y>0 && is_Integer(x) && is_Integer(y))
- ! S$ E\\" h V! O5 d. {# S
- return itop + (z-1)*33 -cur;
- 8 a. @) M: E; r
- }
- 8 ]$ V- q [9 T; ^
- return 0;( B5 j& E\\" G+ d4 k
- }) q* f) q$ k- @9 k
- , y1 ?0 r8 ]0 [+ D- ~1 {
- bool is_Integer(float n)
- % c7 v& \2 H# _
- {' l! S l- \5 I6 D; v
- if( (int)n - n ==0)
- ' R% R: O* t# H4 f9 T) _; S9 |: `1 b1 m
- return true;) v S- q) z$ o- C8 [& g. Z
- else% N5 M/ J- S2 y: K9 p! ~
- return false;4 H+ W2 J1 D$ e/ E7 M
- }$ R2 G- W* S( x' c1 e. B
- + H& s0 `% L3 _+ q u1 V0 ~; ]
7 ]7 t4 y/ o U4 @7 ^" g8 u3 K |
zan
|