- 在线时间
- 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-10067 X# E8 X5 p: V; }; a& d# g" p
7 s0 [7 }, J& W. y6 V( h' ]在本地VC6.0下测试,得出正确结果, 为什么提交后总是Wrong Answer9 O" Z5 e- |2 I" J
+ P" @1 q4 @* h8 Q0 p现将代码贴出,请帮忙看看:. K- B% g: L D0 C
 - #include <iostream>
- # @0 R* p; K0 X L$ `* ^
- using namespace std;/ X& a. P3 N9 p* x2 B- g& A- ?
- #define PH 0+ [+ F' J! B% L# M* A3 ^
- #define EM 12 c4 ] L* a, l# ~* z1 a+ c- Z
- #define IN 2
- 8 }4 Y8 c! m; M9 L h. e$ P
- int get_Top(int days, int kind);4 w+ ^3 _( S1 I7 e
- int triple(int ptop, int etop, int itop, int cur);. l& ^4 E% R3 d
- bool is_Integer(float n);
- . q9 ^/ B+ U* ~: U. I7 M! d% L& ^
- int main()
- 4 o\\" n$ q' y& I\\" d' ?; K- N
- {- X2 g$ x* b \6 U
- int ptop, etop, itop;( q5 Y8 [0 M+ }$ G
- int pdays, edays, idays, curdays;8 t1 Z+ ?- z/ U& D# v
- int count =0;- Y9 q9 Z6 Y9 R
- / g3 R- K* e+ m9 g' U* g2 W `
- while(cin >> pdays >> edays >> idays >> curdays)
- 5 i# g7 k: z& U+ \: |
- {# b m! ?% A& I0 @0 L
- if(pdays==edays&&pdays==idays&&pdays==curdays&&pdays==-1)
- R- f/ l1 n% V1 A: Y2 }8 A! p
- break;
- & C2 d9 V\\" d9 }4 U% N
- count++;% x1 \+ s' d3 j
- ptop = get_Top(pdays,PH);* P! S, u; h# y, E7 b. T- ?
- etop = get_Top(edays,EM);5 ?/ s+ J4 d* c% P7 M! J! W! ~
- itop = get_Top(idays,IN);
- . `, c+ C, Q' |( l4 e, |! k
- cout<<"Case "<<count<<": "<<"the next triple peak occurs in "<<triple(ptop, etop, itop, curdays)<<" days.";+ B& z& Z* L3 N% F, C/ n+ U Z
- }6 E4 b- ~6 Z\\" h
- 4 w# }2 [, u. `! d
- return 0;
- , I6 l$ {. k2 k! y( Y3 \
- }& |+ c: J/ G' d/ N- T% j\\" S
- int get_Top(int days, int kind)8 _\\" g; z; f# _; k
- {; [* M( r9 H3 _
- switch(kind): U. n* M; g+ @$ Q& A
- {6 D) ]6 }0 t1 l' p1 z0 r5 L1 K
- case 0:4 v4 k# D: v* c4 @2 W
- return days%23;: w0 n. o+ N! v\\" D
- case 1:! c7 \7 ^6 U! n3 ~5 R2 w) o
- return days%28;! M- ]( M# U( Q1 L* v4 c* R
- case 2:+ P, V\\" f9 B& r
- return days%33;- i, X/ P- e0 ]* S0 M1 V
- }
- 6 ~- }9 V8 N: ?/ R$ f) }
- return 0;: {3 K) H* a- w- b
- }
- 6 z; ]: l# c# \( x% Z
- 2 ?2 W: N+ X1 Z& U3 D
- int triple(int ptop, int etop, int itop, int cur)
- $ P8 c\\" X' |: l7 x$ G7 |
- {
- 7 B! ^( D: E* f\\" q
- float x, y, z;
- 6 q' ^, E7 q; W0 ?3 C
- int m1 = etop-ptop-5, J9 J' ^7 r) `1 S. S, O
- m2 = itop-etop-5;% W+ i$ q8 r# l- O3 l\\" d% x
- int temp = 0;0 u# T. F$ ?4 Z\\" M
- for(z=2; (itop+(z-1)*33) <= 21252; z++)4 u# d, X1 a8 P
- {
- 8 K6 @! h/ U5 v# R0 Z* a
- temp = m2 + 33*z;& ^6 ?% ]7 I# n7 T/ x
- y = (float)temp/28;7 Z% k' {; z5 B! a( B
- x = (float)(m1+temp)/23;1 a/ D; ~: ~0 M: p0 ^+ G2 d
- if(x>0 && y>0 && is_Integer(x) && is_Integer(y))
- ^% b* }1 @. }; G
- return itop + (z-1)*33 -cur;
- $ o3 ?9 l7 ~+ N1 R; \) M
- }7 @- j+ K; s5 n
- return 0;; ~' n2 D0 h! a4 p9 {\\" p
- }
- 1 c) z4 A7 q\\" {4 p
- ! c% M' K! n( V6 V/ b
- bool is_Integer(float n)
- + c( U/ V3 X; `) J! |
- {' p\\" w/ b# Y5 Q
- if( (int)n - n ==0)7 G) W2 Z) @, [5 z\\" D: [
- return true;
- - X. N3 `/ m9 i3 W T
- else
- 0 o2 x\\" H- g+ Z, g4 T
- return false;
- 0 f0 Z! E* q9 _6 F2 |
- }
- 5 R) D$ q# O6 x\\" n
- 3 E5 Z5 L: }& @: |. q
4 h5 A( m2 t; I
|
zan
|