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 |
为什么错? 我的思路是:贪心,尽量让最多的Xi=sqrt(a), 多出来的mod个中mod-1个取-1/sqrt(a), mod中的最后一个取和mod-1个-1/sqrt(a)加起来相抵消的正数; #include <iostream> #include <cmath> using namespace std; _int64 m, p, a, b; void work() { int bit = a; int mus_p=0,mus_n=0; if(b>0) { mus_p = b; } if(b<0) { mus_n = -1*b*a; } int left = m - mus_p-mus_n; int pl = left/(a+1);// int n = pl*a; // int mod1 = left%(a+1); int m_n = mod1-1; double m_p_t = (double)(m_n)/sqrt((double)a); double rst =0.0; rst +=(double)(mus_p+pl) * pow( (double)a,(double)(p/2)); rst +=(double)(mus_n + n + m_n) * pow(1.0/(double)a,(double)(p/2)); rst +=pow(m_p_t,(double)p); printf("%.0f\n",rst); } int main() { while (scanf("%d%d%d%d",&m,&p,&a,&b)!=EOF) { work(); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator