Problem of Precision
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 1225 Accepted Submission (s): 730
Problem Description
Inputthe first line of input gives the number of cases, T. t test cases follow, each on a separate line. Each test case contains one positive integer n. (1 <= n <= 10^9)
Outputfor each input case, you should output the answer on one line.
Sample Input3125
Sample Output997841
Sourcehdoj Summer Exercise (4)-Buffet Dinner
Recommendlcy | We have carefully selected several similar problems for you:3117 2254 1588 2294 2276 According to the test instructions push, the code is simple, the key is the reasoning process. Stick to someone else's idea: Test instructions: Give a formula, evaluate. Attached code:
1#include <iostream>2#include <cstdio>3#include <cstring>4 #defineMoD 10245 using namespacestd;6 structMat7 {8 intm[2][2];9 };Ten One Mat Mul (Mat A,mat b) A { - Mat C; - inti,j,k; thememset (C.M,0,sizeof(C.M)); - for(i=0; i<2; i++) - for(j=0; j<2; J + +) - { + for(k=0; k<2; k++) -c.m[i][j]+= (A.m[i][k]*b.m[k][j])%MoD; +c.m[i][j]%=MoD; A } at returnC; - } - -Mat Product (Mat A,intk) - { - if(k==1)returnA; in Else if(k&1)returnMul (Product (a,k-1), a); - Else returnProduct (Mul (a,a), k/2); to } + - intMain () the { * intt,i,j,n,m; $ Mat A, B;Panax Notoginsengscanf"%d",&T); - while(t--) the { +scanf"%d",&n); A if(n==1) the { +printf"9\n"); - Continue; $ } $a.m[0][0]=5; -a.m[0][1]= A; -a.m[1][0]=2; thea.m[1][1]=5; -B=product (a,n-1);Wuyi intAns= (b.m[0][0]*5+b.m[0][1]*2)%MoD; theAns= (ans*2-1)%MoD; -printf"%d\n", ans); Wu } - return 0; About}
Hdu 2256 Problem of Precision