| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:总结三点In Reply To:Re:总结三点 Posted by:acm79 at 2012-08-24 16:15:51 > 我怎么解出来的解跟m递增的时候解出来的解不一样呢。。我都输出来看了,有的相同有的不同。。请大牛指教。
> #include <algorithm>
> #include <iostream>
> #include <cstdio>
> #include <cstring>
> #include <cstdlib>
>
> using namespace std;
>
> int main()
> {
> int k,s,p,m,i,ans[14]={0};
> for(k=1;k<14;k++)
> {
> p=0;
> for(int s=0; ;s++)
> {
> m=s*1;
> //m=s*(k+1);或者m=s*(k+1)+1;的时候算不出正解来,虽然书上是这么说的。
> for(i=1;i<=k;i++)
> {
> int rest=2*k-i+1;
> p=(p+m-1)%rest;
> if(p<k)
> {
> p=0;
> break;
> }
> }
> if(i==k+1)
> {
> ans[k]=m;
> break;
> }
> }
> printf("%d\n",ans[k]);
> system("pause");
> }
> // while(scanf("%d",&k),k)
> // {
> // printf("%d\n",ans[k]);
> // }
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator