[杂题]CSUOJ1413 Area of a Fractal
2014-12-08 22:41
204 查看
题目链接
题意:题中给了图,所以不看字大概也知道
求的是第n个图形的面积。
就是找规律 递推 一类的...
先给结论:
很鬼畜的公式: $\displaystyle\frac{3\times 17^n+2\times 7^n}{5}$
递推式是: $\displaystyle S_n = S_{n-1}\times 17-4\times 7^{n-1}$
重点在于17和7是怎么来的。
在题图的基础上画些个框框
CSUOJ 1413
题意:题中给了图,所以不看字大概也知道
求的是第n个图形的面积。
就是找规律 递推 一类的...
先给结论:
很鬼畜的公式: $\displaystyle\frac{3\times 17^n+2\times 7^n}{5}$
递推式是: $\displaystyle S_n = S_{n-1}\times 17-4\times 7^{n-1}$
重点在于17和7是怎么来的。
在题图的基础上画些个框框
#include <cstdio> #include <cstdlib> #include <cstring> #include <climits> #include <cctype> #include <cmath> #include <string> #include <sstream> #include <iostream> #include <algorithm> #include <iomanip> using namespace std; #include <queue> #include <stack> #include <vector> #include <deque> #include <set> #include <map> typedef long long LL; typedef long double LD; const double pi=acos(-1.0); const double eps=1e-6; #define INF 0x3f3f3f #define lson l, m, rt<<1 #define rson m+1, r, rt<<1|1 typedef pair<int, int> PI; typedef pair<int, PI > PP; #ifdef _WIN32 #define LLD "%I64d" #else #define LLD "%lld" #endif //#pragma comment(linker, "/STACK:1024000000,1024000000") //LL quick(LL a, LL b){LL ans=1;while(b){if(b & 1)ans*=a;a=a*a;b>>=1;}return ans;} //inline int read(){char ch=' ';int ans=0;while(ch<'0' || ch>'9')ch=getchar();while(ch<='9' && ch>='0'){ans=ans*10+ch-'0';ch=getchar();}return ans;} inline void print(LL x){printf(LLD, x);puts("");} //inline void read(LL &ret){char c;int sgn;LL bit=0.1;if(c=getchar(),c==EOF) return ;while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();sgn=(c=='-')?-1:1;ret=(c=='-')?0:(c-'0');while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');if(c==' '||c=='\n'){ ret*=sgn; return ; }while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;ret*=sgn;} const int mod=1000000007; LL quick(LL a, LL b) { LL ans=1; while(b) { if(b & 1)ans=(ans*a)%mod; a=(a*a)%mod; b>>=1; } return ans%mod; } void ex_gcd(int a, int b, int &x, int &y) { if(b) { ex_gcd(b, a%b, x, y); int tmp=x; x=y; y=tmp-(a/b)*y; } else { x=1, y=0; return ; } } int main() { int t; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); if(n==0) { printf("1\n"); continue; } int x, y; ex_gcd(5, mod, x, y); print((((3*quick(17, n))%mod+(2*quick(7, n))%mod)*x)%mod); } return 0; }
CSUOJ 1413
相关文章推荐
- Light 1305 - Area of a Parallelogram【向量求解】
- Hdu 4946 Area of Mushroom
- HDU 4946 Area of Mushroom(共线凸包)
- hdu 4946 Area of Mushroom 共线凸包 附赠数据,点击就送
- [矩阵快速幂] Atcoder AGC003 F. Fraction of Fractal
- The Area of an Arbitrary Triangle-任意三角形的面积
- Simple test ----Compute the area of a circle
- hdu 4946 Area of Mushroom 计算几何
- Area of Interest
- Hiding Data from Forensic Imagers – Using the Service Area of a Hard Disk Drive
- Aizu 2164 CSUOJ 1436 Revenge of the Round Table
- POJ 1389 Area of Simple Polygons(线段树+扫描线求矩形面积并)
- Area of Simple Polygons
- 1437 [CA1006]The area of triangle
- 【POJ 1389】Area of Simple Polygons(线段树+扫描线)
- LeetCode: Max Area of Island
- SPOJ CIRU The area of the union of circles ——Simpson积分
- LeetCode Max Area of Island
- POJ 1389 Area of Simple Polygons(线段树+扫描线+离散化)
- LightOJ 1305 Area of a Parallelogram - Basic Geometry