Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:贴代码,请指教~~我觉得已经无法再简了

Posted by Fusojyan at 2016-02-04 20:50:44 on Problem 1006
In Reply To:贴代码,请指教~~我觉得已经无法再简了 Posted by:1064232633 at 2015-06-14 00:12:47
> #include <stdio.h>
> 
> int main(){
>     int p,i,e,d,x,j = 1;
>     while(scanf("%d %d %d %d",&p,&i,&e,&d) && p!=-1){
>         x = (p * 5544 + i * 14421 + e * 1288 + 21252 - d) % 21252;
>         printf("Case %d: the next triple peak occurs in %d days.\n",j++,x?x:21252);
>     }   
>     return 0;
> }
> 
> 主要思路是用中国剩余定理提前算出那三个系数,最后直接把系数填上就可以了。

我的:
#include<cstdio>  
int main(){  
    int a,b,c,d,ans,T=0;
    while(~scanf("%d%d%d%d",&a,&b,&c,&d)&&(a>=0||b>=0||c>=0||d>=0))
        printf("Case %d: the next triple peak occurs in %d days.\n",++T,(ans=(5544*a+14421*b+1288*c-d+21252)%21252)?ans:21252);
    return 0;  
}  

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator