# 某岛

… : "…アッカリ～ン . .. . " .. .
November 7, 2010

## 校赛。。

#include
using namespace std ;

int   N ;
int   a1 , a2 , s1 , s2 , F[10000001] ;

void	Init()
{
a1 = 5 ; a2 = 401 % 29 ;
s1 = 6 ; s2 = 402 % 29 ;
F[1] = 5 ;
for ( int i = 2 ; i <= 10000000 ; i ++ )
{
a1 = ( a1 * 5   ) % 29 ;
a2 = ( a2 * 401 ) % 29 ;
F[i] = ( F[i-1] + s1 * a2 + s2 * a1 + a1 * a2 ) % 29 ;
s1 = (s1 + a1) % 29 ;
s2 = (s2 + a2) % 29 ;
}
}

int		main()
{
Init() ;
while ( cin >> N && N != 0 ) cout << F[N] << "\n" ;
return 0 ;
}


/* This Code is Submitted by xiaodao for Problem 101449 at 2010-11-07 13:55:43 */
#include
using namespace std;
const int N = 366;
int g[N], f[N]; double a[N];
// f:.. Cana.   g:.. Usa.
double ans;
int n;

void init(){
for (int i=1;i<=n;i++){
scanf("%lf", &a[i]);
// a[i] = a[i]*0.97;
}
}

void solve(){
f[0] = 100000; g[0] = 0;
for (int i=1;i<=n;i++){
f[i] = max(f[i-1], int(g[i-1]*a[i]*0.97));
g[i] = max(g[i-1], int(f[i-1]/a[i]*0.97));
}

}

int main(){
cin >> n;
while (n!=0){
init(); solve(); ans = double(f[n]) / 100;
printf("%.2lf\n", ans);
//cout << f[n]/100 << endl;
cin >> n;
}

}

#include
#include
using namespace std;
const int N = 10;
int A[N+1];
string s;
int x;

string f(int x){
string res;

if (x < 0) {
res = ""; x = -x;

while (x!=0){
res = char( x%10 + 48) + res;
x /= 10;
}

if (res=="") res = '0';

res = "-" + res;
}
else {
while (x!=0){
res = char(x%10 + 48) + res;
x /= 10;
}

if (res=="") res = '0';

res = "+" + res;
}

return res;
}

string g(int x){

if (x == 0) return "";
if (x == 1) return "x";

string res = "x^"; res += char(x + 48);
return res;
}

void encode(){

s = "+" + s;

int x;
for (int i=0;i=0;i--)
if (A[i]!=0) s = s + f(A[i]) + g(i);

if (s[0]=='+') s.erase(0, 1);

cout << s << endl;
}

void derivate(){
for (int i=0;i> x; cin >> s; cout << s << endl;
}

void solve(){
memset(A, 0, sizeof(A));
encode();

int i;
for (i=1;i> T;
for (int i=1;i<=T;i++){
cout << "POLYNOMIAL " << i << endl;
init(); solve();
}

}


Solution for Problem A ：

Problem_A_____________________________________________________________
____Description:_求2005^X的所有因数的和 mod 29________________________
____Solution___:_首先，2005是由401和5这2个质数相乘的。________________
_________________我们考虑2005^X与2005^(X-1)___________________________
_________________与2005^(X-1)相比，2005^X多出来的因数有：_____________
_____________________(1)_5^i_*_401^X__________________________________
_____________________(2)_5^X_*_401^i__________________________________
_________________于是我们用s1,s2分别记录前X-1个5的幂和401的幂的和_____
_________________于是_F[X]_=_F[X-1]_+_s1*401^X_+_s2*5^X_+_5^X*401^X___
_________________递推求出所有的答案，打表。时间复杂度度O(N)___________

Problem_B_____________________________________________________________
____Description:_求用1*2的骨牌和3拐的骨牌覆盖2*N的棋盘的方案个数______
____Solution___:_用0、1、2、3表示4种状态______________________________
____________________0、□___1、□___2、■___3、■_____________________
_______________________□______■______□______■_____________________
_________________于是我们得到下面的关系矩阵___________________________
________________________|0___1___2___3________________________________
______________________--+--------------_______________________________
______________________0_|0___1___1___1________________________________
______________________1_|0___0___1___1________________________________
______________________2_|0___1___0___1________________________________
______________________3_|1___0___0___1________________________________
_________________用快速幂矩阵乘法DP即可。_____________________________