poj1006中国剩余定理
2014-08-03 16:23
253 查看
x=ai(%mi)(i=1..n)
find min xi,xi*pi(j)=(%mi)(i==1..n)(j!=i)
ans=sigma(xi*pi(j)*ai)%lcm(mi)(i=1..n)(j!=i)
find min xi,xi*pi(j)=(%mi)(i==1..n)(j!=i)
ans=sigma(xi*pi(j)*ai)%lcm(mi)(i=1..n)(j!=i)
/************************************************************************* > File Name: poj1006.cpp > Author: flyasdfvcxz > Mail: flyasdfvcxz@yahoo.com > Created Time: 2014年08月03日 星期日 15时28分19秒 ************************************************************************/ #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cctype> #include<cstdlib> #include<ctime> #include<cmath> #include<string> #include<set> #include<vector> #include<map> #include<queue> #include<stack> #include<iomanip> using namespace std; #define N 21252 #define ll long long const int inf=~0U>>1; const double eps=1e-6; int a,b,c,d; void init() { for(a=0;a<N;a++) if(a*33*28%23==1)break; for(b=0;b<N;b++) if(b*23*33%28==1)break; for(c=0;c<N;c++) if(c*28*23%33==1)break; } int main() { init(); int cas=0; int x,y,z,d; while(cin>>x>>y>>z>>d) { if(x==-1 && y==-1 && z==-1 && d==-1)break; int ans=(28*33*a*x+23*33*b*y+23*28*c*z+N-d)%N; if(ans==0)ans=N; printf("Case %d: the next triple peak occurs in %d days.\n",++cas,ans); } return 0; }
相关文章推荐
- POJ 1006 Biorhythms 中国剩余定理
- 20140714 「初等数论 - 中国剩余定理」 POJ 1006 Biorhythms
- POJ 1006 Biorhythms 中国剩余定理
- poj1006 Biorhythms<中国剩余定理>
- poj 1006 中国剩余定理模板
- POJ 1006 Biorhythms 中国剩余定理
- poj-1006-中国剩余定理
- POJ 1006 中国剩余定理
- hdu 1370 || poj 1006 简单的中国剩余定理或者暴力
- POJ1006 Biorhythms(生理周期,中国剩余定理详述)
- POJ 1006 ——Biorhythms 中国剩余定理模板
- POJ1006: 中国剩余定理的完美演绎
- POJ 1006 中国剩余定理(孙子定理) ——数论
- POJ1006-Biorhythms 中国剩余定理
- poj 1006 中国剩余定理模板
- poj 1006(中国剩余定理的应用)
- POJ1006: 中国剩余定理的完美演绎
- POJ 1006 Java:中国剩余定理
- POJ 1006 Biorhythms 中国剩余定理
- 【中国剩余定理】 poj 1006