昨天和前天分别是2,3点睡觉的,感觉身体被掏空(ノಥ益ಥ),大数减除等等吧。
先附上快速幂的代码:
#includeint main() { int a,b,t=1; scanf("%d %d",&a,&b);//a=底数,b=次幂 while(b)//b!=0进入循环 { if(b%2==0) { b=b/2; a=a*a; } else { b=b-1; t=t*a; } } printf("%d",t); }
还刷了几道题,如下:
蛇形填数:
在 n×n 方阵里填入 1,2, ⋯,n×n,要求填成蛇形。例如 n=4 时方阵为:
10 11 12 1 9 16 13 2 8 15 14 3 7 6 5 4输入格式
直接输入方阵的维数,即 n的值。(n≤100)
输出格式输出结果是蛇形方阵。
Sample Input
3
Sample Output
7 8 1 6 9 2 5 4 3
#include#include int main() { int n; scanf("%d",&n); int a[n][n]; int i=0,z=1,r=0,t=0; while(z =1+t;i--) { a[n-1-t][i]=z; z++; } for(i=n-1-t;i>=1+t;i--) { a[i][t]=z; z++; } for(i=t;i 想了好久.....;
螺旋:
Spira 是一种螺旋,从 Spiral 演变过来的。废话不多说,蒜头君决定称如下的等腰直角三角形为 Spira:
1 2 3 4 5 12 13 14 6 11 15 7 10 8 9这个是腰长为 55 的时候的样子。那么如果有其它腰长的 Spira 会是怎么样的呢?蒜头君想让你一个个画出来。
输入格式第一行一个正整数 T(1 le T le 10)T(1≤T≤10),代表测试数据组数。
以下 TT 行,各行就一个正整数 N(2 le N le 1000)N(2≤N≤1000),代表三角形腰长。
输出格式对于每个测试数据,输出相应的 Spira。每组数据之间以一个空行来间隔。
Sample Input
2 5 4Sample Output
1 2 3 4 5 12 13 14 6 11 15 7 10 8 9 1 2 3 4 9 10 5 8 6 7#include#define N 1001 int b[3][2]= {{0,1},{1,-1},{-1,0}}; int a[N][N]; int main() { int n,t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int f=1; int t1,t2; t1=0; t2=0; for(int i=0; i 今天学习目标没有达到啊,找机会补上吧。
先(¦3[▓▓].....



